当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::getCacheGeneral方法代码示例

本文整理汇总了PHP中Piwik\Tracker\Cache::getCacheGeneral方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::getCacheGeneral方法的具体用法?PHP Cache::getCacheGeneral怎么用?PHP Cache::getCacheGeneral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Tracker\Cache的用法示例。


在下文中一共展示了Cache::getCacheGeneral方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_getNumUsableCustomVariables_ShouldReadFromCacheIfPossible

 public function test_getNumUsableCustomVariables_ShouldReadFromCacheIfPossible()
 {
     $cache = Cache::getCacheGeneral();
     $cache['CustomVariables.NumUsableCustomVariables'] = 10;
     Cache::setCacheGeneral($cache);
     $this->assertSame(10, CustomVariables::getNumUsableCustomVariables());
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:CustomVariablesTest.php

示例2: runScheduledTasks

 /**
  * Tracker requests will automatically trigger the Scheduled tasks.
  * This is useful for users who don't setup the cron,
  * but still want daily/weekly/monthly PDF reports emailed automatically.
  *
  * This is similar to calling the API CoreAdminHome.runScheduledTasks
  */
 public function runScheduledTasks()
 {
     $now = time();
     // Currently, there are no hourly tasks. When there are some,
     // this could be too aggressive minimum interval (some hours would be skipped in case of low traffic)
     $minimumInterval = TrackerConfig::getConfigValue('scheduled_tasks_min_interval');
     // If the user disabled browser archiving, he has already setup a cron
     // To avoid parallel requests triggering the Scheduled Tasks,
     // Get last time tasks started executing
     $cache = Cache::getCacheGeneral();
     if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerEnabled'])) {
         Common::printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled.");
         return;
     }
     $nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval;
     if (defined('DEBUG_FORCE_SCHEDULED_TASKS') && DEBUG_FORCE_SCHEDULED_TASKS || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now) {
         $cache['lastTrackerCronRun'] = $now;
         Cache::setCacheGeneral($cache);
         Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']);
         Common::printDebug('-> Scheduled Tasks: Starting...');
         $invokeScheduledTasksUrl = "?module=API&format=csv&convertToUnicode=0&method=CoreAdminHome.runScheduledTasks&trigger=archivephp";
         $cliMulti = new CliMulti();
         $cliMulti->runAsSuperUser();
         $responses = $cliMulti->request(array($invokeScheduledTasksUrl));
         $resultTasks = reset($responses);
         Common::printDebug($resultTasks);
         Common::printDebug('Finished Scheduled Tasks.');
     } else {
         Common::printDebug("-> Scheduled tasks not triggered.");
     }
     Common::printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC');
 }
开发者ID:cemo,项目名称:piwik,代码行数:39,代码来源:ScheduledTasksRunner.php

示例3: test_storageCreateACacheEntryIfNoCacheExistsYet

 public function test_storageCreateACacheEntryIfNoCacheExistsYet()
 {
     $cache = Cache::getCacheGeneral();
     $this->assertArrayNotHasKey('settingsStorage', $cache);
     // make sure there is no cache entry yet
     $this->setSettingValueAndMakeSureCacheGetsCreated('myVal');
     $cache = $this->getCache()->fetch($this->storage->getOptionKey());
     $this->assertEquals(array($this->setting->getKey() => 'myVal'), $cache);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:SettingsStorageTest.php

示例4: getFromTrackerCache

 private function getFromTrackerCache($name, $config)
 {
     $name = $this->prefix($name);
     $cache = Cache::getCacheGeneral();
     if (array_key_exists($name, $cache)) {
         $value = $cache[$name];
         settype($value, $config['type']);
         return $value;
     }
     return $config['default'];
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:11,代码来源:Config.php

示例5: getMaxCustomVariables

 public static function getMaxCustomVariables()
 {
     $cache = Cache::getCacheGeneral();
     $cacheKey = 'CustomVariables.MaxNumCustomVariables';
     if (!array_key_exists($cacheKey, $cache)) {
         $maxCustomVar = 0;
         foreach (Model::getScopes() as $scope) {
             $model = new Model($scope);
             $highestIndex = $model->getHighestCustomVarIndex();
             if ($highestIndex > $maxCustomVar) {
                 $maxCustomVar = $highestIndex;
             }
         }
         $cache[$cacheKey] = $maxCustomVar;
         Cache::setCacheGeneral($cache);
     }
     return $cache[$cacheKey];
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:18,代码来源:CustomVariables.php

示例6: getNumUsableCustomVariables

 /**
  * Returns the number of available custom variables that can be used.
  *
  * "Can be used" is identifed by the minimum number of available custom variables across all relevant tables. Eg
  * if there are 6 custom variables installed in log_visit but only 5 in log_conversion, we consider only 5 custom
  * variables as usable.
  * @return int
  */
 public static function getNumUsableCustomVariables()
 {
     $cache = Cache::getCacheGeneral();
     $cacheKey = 'CustomVariables.NumUsableCustomVariables';
     if (!array_key_exists($cacheKey, $cache)) {
         $minCustomVar = null;
         foreach (Model::getScopes() as $scope) {
             $model = new Model($scope);
             $highestIndex = $model->getHighestCustomVarIndex();
             if (!isset($minCustomVar)) {
                 $minCustomVar = $highestIndex;
             }
             if ($highestIndex < $minCustomVar) {
                 $minCustomVar = $highestIndex;
             }
         }
         if (!isset($minCustomVar)) {
             $minCustomVar = 0;
         }
         $cache[$cacheKey] = $minCustomVar;
         Cache::setCacheGeneral($cache);
     }
     return $cache[$cacheKey];
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:32,代码来源:CustomVariables.php

示例7: runScheduledTasks

 /**
  * Tracker requests will automatically trigger the Scheduled tasks.
  * This is useful for users who don't setup the cron,
  * but still want daily/weekly/monthly PDF reports emailed automatically.
  *
  * This is similar to calling the API CoreAdminHome.runScheduledTasks
  */
 protected static function runScheduledTasks()
 {
     $now = time();
     // Currently, there are no hourly tasks. When there are some,
     // this could be too aggressive minimum interval (some hours would be skipped in case of low traffic)
     $minimumInterval = Config::getInstance()->Tracker['scheduled_tasks_min_interval'];
     // If the user disabled browser archiving, he has already setup a cron
     // To avoid parallel requests triggering the Scheduled Tasks,
     // Get last time tasks started executing
     $cache = Cache::getCacheGeneral();
     if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerEnabled'])) {
         Common::printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled.");
         return;
     }
     $nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval;
     if (isset($GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) && $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now) {
         $cache['lastTrackerCronRun'] = $now;
         Cache::setCacheGeneral($cache);
         self::initCorePiwikInTrackerMode();
         Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']);
         Common::printDebug('-> Scheduled Tasks: Starting...');
         // save current user privilege and temporarily assume Super User privilege
         $isSuperUser = Piwik::hasUserSuperUserAccess();
         // Scheduled tasks assume Super User is running
         Piwik::setUserHasSuperUserAccess();
         // While each plugins should ensure that necessary languages are loaded,
         // we ensure English translations at least are loaded
         Translate::loadEnglishTranslation();
         ob_start();
         CronArchive::$url = SettingsPiwik::getPiwikUrl();
         $cronArchive = new CronArchive();
         $cronArchive->runScheduledTasksInTrackerMode();
         $resultTasks = ob_get_contents();
         ob_clean();
         // restore original user privilege
         Piwik::setUserHasSuperUserAccess($isSuperUser);
         foreach (explode('</pre>', $resultTasks) as $resultTask) {
             Common::printDebug(str_replace('<pre>', '', $resultTask));
         }
         Common::printDebug('Finished Scheduled Tasks.');
     } else {
         Common::printDebug("-> Scheduled tasks not triggered.");
     }
     Common::printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC');
 }
开发者ID:Abine,项目名称:piwik,代码行数:52,代码来源:Tracker.php

示例8: getCurrentLocationProviderId

 /**
  * Returns the ID of the current LocationProvider (see UserCountry plugin code) from
  * the Tracker cache.
  */
 public static function getCurrentLocationProviderId()
 {
     $cache = TrackerCache::getCacheGeneral();
     return empty($cache['currentLocationProviderId']) ? DefaultProvider::ID : $cache['currentLocationProviderId'];
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:9,代码来源:Common.php

示例9: getCachedInstalledIndexesForScope

 public function getCachedInstalledIndexesForScope($scope)
 {
     $cache = Cache::getCacheGeneral();
     $key = 'custom_dimension_indexes_installed_' . $scope;
     if (empty($cache[$key])) {
         return array();
     }
     return $cache[$key];
 }
开发者ID:piwik,项目名称:plugin-CustomDimensions,代码行数:9,代码来源:CustomDimensions.php

示例10: getCachedUrlsByHostAndIdSite

 private function getCachedUrlsByHostAndIdSite()
 {
     $cache = Cache::getCacheGeneral();
     if (!empty($cache['allUrlsByHostAndIdSite'])) {
         return $cache['allUrlsByHostAndIdSite'];
     }
     return array();
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:8,代码来源:Base.php

示例11: detectReferrerDirectEntry

 /**
  * We have previously tried to detect the campaign variables in the URL
  * so at this stage, if the referrer host is the current host,
  * or if the referrer host is any of the registered URL for this website,
  * it is considered a direct entry
  * @return bool
  */
 protected function detectReferrerDirectEntry()
 {
     if (empty($this->referrerHost)) {
         return false;
     }
     $cache = Cache::getCacheGeneral();
     if (!empty($cache['allUrlsByHostAndIdSite'])) {
         $directEntry = new SiteUrls();
         $matchingSites = $directEntry->getIdSitesMatchingUrl($this->referrerUrlParse, $cache['allUrlsByHostAndIdSite']);
         if (isset($matchingSites) && is_array($matchingSites) && in_array($this->idsite, $matchingSites)) {
             $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY;
             return true;
         } elseif (isset($matchingSites)) {
             return false;
         }
     }
     // fallback logic if the referrer domain is not known to any site to not break BC
     if (isset($this->currentUrlParse['host'])) {
         // this might be actually buggy if first thing tracked is eg an outlink and referrer is from that site
         $currentHost = Common::mb_strtolower($this->currentUrlParse['host']);
         if ($currentHost == Common::mb_strtolower($this->referrerHost)) {
             $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY;
             return true;
         }
     }
     return false;
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:34,代码来源:Base.php

示例12: test_save_shouldClearTrackerCacheEntries

 public function test_save_shouldClearTrackerCacheEntries()
 {
     $this->setSuperUser();
     Cache::setCacheGeneral(array('testSetting' => 1));
     $this->assertArrayHasKey('testSetting', Cache::getCacheGeneral());
     $this->addSystemSetting('mysystemsetting2', 'mytitle2');
     $this->settings->save();
     $this->assertArrayNotHasKey('testSetting', Cache::getCacheGeneral());
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:SettingsTest.php

示例13: test_shouldCacheInstalledIndexes

 public function test_shouldCacheInstalledIndexes()
 {
     Cache::clearCacheGeneral();
     $cache = Cache::getCacheGeneral();
     $test = array(CustomDimensions::SCOPE_VISIT => range(1, 5), CustomDimensions::SCOPE_ACTION => range(1, 5), CustomDimensions::SCOPE_CONVERSION => range(2, 5));
     foreach (CustomDimensions::getScopes() as $scope) {
         $key = 'custom_dimension_indexes_installed_' . $scope;
         $this->assertArrayHasKey($key, $cache);
         $this->assertSame(range(1, 5), $cache[$key]);
     }
 }
开发者ID:ep123,项目名称:plugin-CustomDimensions,代码行数:11,代码来源:CustomDimensionsTest.php

示例14: isActiveInTracker

 /**
  * Returns true if DoNotTrack header checking is enabled. This function is called by the
  * Tracker.
  */
 private function isActiveInTracker()
 {
     $cache = Cache::getCacheGeneral();
     return !empty($cache[self::OPTION_NAME]);
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:9,代码来源:DoNotTrackHeaderChecker.php


注:本文中的Piwik\Tracker\Cache::getCacheGeneral方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。