Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Piwik - free/libre analytics platform
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- */
- namespace Piwik\Plugins\QueuedTracking;
- use Piwik\Tracker\Cache;
- class Config
- {
- private $cachedConfig;
- public function getRedisHost()
- {
- return $this->getFromTrackerCache('redisHost');
- }
- public function getRedisPort()
- {
- return $this->getFromTrackerCache('redisPort');
- }
- public function getRedisTimeout()
- {
- return $this->getFromTrackerCache('redisTimeout');
- }
- public function getRedisPassword()
- {
- return $this->getFromTrackerCache('redisPassword');
- }
- public function isQueueEnabled()
- {
- return $this->getFromTrackerCache('queueEnabled');
- }
- public function getNumRequestsToProcess()
- {
- return $this->getFromTrackerCache('numRequestsToProcess');
- }
- public function shouldProcessDuringTrackingRequest()
- {
- return $this->getFromTrackerCache('processDuringTrackingRequest');
- }
- private function getFromTrackerCache($name)
- {
- $this->loadCachedConfigIfNeeded();
- $name = $this->prefix($name);
- if (array_key_exists($name, $this->cachedConfig)) {
- return $this->cachedConfig[$name];
- }
- }
- private function loadCachedConfigIfNeeded()
- {
- if (is_null($this->cachedConfig)) {
- $this->cachedConfig = Cache::getCacheGeneral();
- }
- if (empty($this->cachedConfig)) {
- $this->cachedConfig = array();
- }
- }
- private function prefix($optionName)
- {
- return 'QueuedTracking.' . $optionName;
- }
- public function setTrackerCacheGeneral($cacheContent)
- {
- $settings = new Settings();
- $cacheContent[$this->prefix('redisHost')] = $cacheContent[$settings->redisHost->getValue()];
- $cacheContent[$this->prefix('redisPort')] = $cacheContent[$settings->redisPort->getValue()];
- $cacheContent[$this->prefix('redisPassword')] = $cacheContent[$settings->redisPassword->getValue()];
- $cacheContent[$this->prefix('redisTimeout')] = $cacheContent[$settings->redisTimeout->getValue()];
- $cacheContent[$this->prefix('queueEnabled')] = $cacheContent[$settings->queueEnabled->getValue()];
- $cacheContent[$this->prefix('processDuringTrackingRequest')] = $cacheContent[$settings->processDuringTrackingRequest->getValue()];
- $cacheContent[$this->prefix('numRequestsToProcess')] = $cacheContent[$settings->numRequestsToProcess->getValue()];
- return $cacheContent;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement