本文整理匯總了PHP中Piwik_Common::getCacheGeneral方法的典型用法代碼示例。如果您正苦於以下問題:PHP Piwik_Common::getCacheGeneral方法的具體用法?PHP Piwik_Common::getCacheGeneral怎麽用?PHP Piwik_Common::getCacheGeneral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::getCacheGeneral方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 (see misc/cron/archive.sh)
*
* @param int $now Current timestamp
*/
public static function runScheduledTasks($now)
{
// Currently, there is no hourly tasks. When there are some,
// this could be too agressive minimum interval (some hours would be skipped in case of low traffic)
$minimumInterval = Piwik_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 = Piwik_Common::getCacheGeneral();
if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerArchivingEnabled'])) {
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;
Piwik_Common::setCacheGeneral($cache);
Piwik_Common::initCorePiwikInTrackerMode();
Piwik_SetOption('lastTrackerCronRun', $cache['lastTrackerCronRun']);
printDebug('-> Scheduled Tasks: Starting...');
// save current user privilege and temporarily assume super user privilege
$isSuperUser = Piwik::isUserIsSuperUser();
// Scheduled tasks assume Super User is running
Piwik::setUserIsSuperUser();
// While each plugins should ensure that necessary languages are loaded,
// we ensure English translations at least are loaded
Piwik_Translate::getInstance()->loadEnglishTranslation();
$resultTasks = Piwik_TaskScheduler::runTasks();
// restore original user privilege
Piwik::setUserIsSuperUser($isSuperUser);
printDebug($resultTasks);
printDebug('Finished Scheduled Tasks.');
} else {
printDebug("-> Scheduled tasks not triggered.");
}
printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC');
}