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


PHP Cache::setCacheGeneral方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: test_get_shouldReturnCurrentProvider_IfCurrentProviderIsSet

 public function test_get_shouldReturnCurrentProvider_IfCurrentProviderIsSet()
 {
     Cache::setCacheGeneral(array('currentLocationProviderId' => MockLocationProvider::ID));
     $geolocator = new VisitorGeolocator();
     $this->assertEquals(MockLocationProvider::ID, $geolocator->getProvider()->getId());
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:6,代码来源:VisitorGeolocatorTest.php

示例7: 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


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