本文整理汇总了PHP中Piwik\Tracker\Cache类的典型用法代码示例。如果您正苦于以下问题:PHP Cache类的具体用法?PHP Cache怎么用?PHP Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteAllCacheOnUpdate
/**
* Called on Core install, update, plugin enable/disable
* Will clear all cache that could be affected by the change in configuration being made
*/
public static function deleteAllCacheOnUpdate($pluginName = false)
{
AssetManager::getInstance()->removeMergedAssets($pluginName);
View::clearCompiledTemplates();
Cache::deleteTrackerCache();
self::clearPhpCaches();
}
示例2: testGetMaxCustomVariables_ShouldReadFromCacheIfPossible
public function testGetMaxCustomVariables_ShouldReadFromCacheIfPossible()
{
$cache = Cache::getCacheGeneral();
$cache['CustomVariables.MaxNumCustomVariables'] = 10;
Cache::setCacheGeneral($cache);
$this->assertSame(10, CustomVariables::getMaxCustomVariables());
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$numVarsToSet = $this->getNumVariablesToSet($input);
$numChangesToPerform = $this->getNumberOfChangesToPerform($numVarsToSet);
if (0 === $numChangesToPerform) {
$this->writeSuccessMessage($output, array('Your Piwik is already configured for ' . $numVarsToSet . ' custom variables.'));
return;
}
$output->writeln('');
$output->writeln(sprintf('Configuring Piwik for %d custom variables', $numVarsToSet));
foreach (Model::getScopes() as $scope) {
$this->printChanges($scope, $numVarsToSet, $output);
}
if (!$this->confirmChange($output)) {
return;
}
$output->writeln('');
$output->writeln('Starting to apply changes');
$output->writeln('');
$this->progress = $this->initProgress($numChangesToPerform, $output);
foreach (Model::getScopes() as $scope) {
$this->performChange($scope, $numVarsToSet, $output);
}
Cache::clearCacheGeneral();
$this->progress->finish();
$this->writeSuccessMessage($output, array('Your Piwik is now configured for ' . $numVarsToSet . ' custom variables.'));
}
示例4: onSiteDeleted
public function onSiteDeleted($idSite)
{
// we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
Cache::deleteCacheWebsiteAttributes($idSite);
$archiveInvalidator = new ArchiveInvalidator();
$archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
}
示例5: update
static function update($schema = 'Myisam')
{
// force regeneration of cache files following #648
Piwik::setUserIsSuperUser();
$allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}
示例6: 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');
}
示例7: onSiteDeleted
public function onSiteDeleted($idSite)
{
// we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
Cache::deleteCacheWebsiteAttributes($idSite);
$archiveInvalidator = StaticContainer::get('Piwik\\Archive\\ArchiveInvalidator');
$archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
MeasurableSettingsTable::removeAllSettingsForSite($idSite);
}
示例8: setUp
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
Cache::deleteTrackerCache();
$_SERVER['HTTP_USER_AGENT'] = '';
}
示例9: setUp
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
Cache::deleteTrackerCache();
$this->request = $this->buildRequest(array('idsite' => '1'));
}
示例10: getGoalDefinitions
public static function getGoalDefinitions($idSite)
{
$websiteAttributes = Cache::getCacheWebsiteAttributes($idSite);
if (isset($websiteAttributes['goals'])) {
return $websiteAttributes['goals'];
}
return array();
}
示例11: onSiteDeleted
public function onSiteDeleted($idSite)
{
// we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
Cache::deleteCacheWebsiteAttributes($idSite);
$archiveInvalidator = StaticContainer::get('Piwik\\Archive\\ArchiveInvalidator');
$archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
$measurableStorage = new Storage(Db::get(), $idSite);
$measurableStorage->deleteAllValues();
}
示例12: 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);
}
示例13: sendRequest
protected function sendRequest($url, $method = 'GET', $data = null, $force = false)
{
// if doing a bulk request, store the url
if ($this->doBulkRequests && !$force) {
$this->storedTrackingActions[] = $url;
return true;
}
if ($method == 'POST') {
$requests = array();
foreach ($this->storedTrackingActions as $action) {
$requests[] = $this->parseUrl($action);
}
$testEnvironmentArgs = array();
} else {
$testEnvironmentArgs = $this->parseUrl($url);
$requests = array($testEnvironmentArgs);
}
// unset cached values
Cache::$trackerCache = null;
Tracker::setForceIp(null);
Tracker::setForceDateTime(null);
// save some values
$plugins = Config::getInstance()->Plugins['Plugins'];
$oldTrackerConfig = Config::getInstance()->Tracker;
\Piwik\Plugin\Manager::getInstance()->unloadPlugins();
// modify config
$GLOBALS['PIWIK_TRACKER_MODE'] = true;
$GLOBALS['PIWIK_TRACKER_LOCAL_TRACKING'] = true;
Tracker::$initTrackerMode = false;
Tracker::setTestEnvironment($testEnvironmentArgs, $method);
// set language
$oldLang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $this->acceptLanguage;
// set user agent
$oldUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$_SERVER['HTTP_USER_AGENT'] = $this->userAgent;
// set cookie
$oldCookie = $_COOKIE;
// parse_str(parse_url($this->requestCookie, PHP_URL_QUERY), $_COOKIE);
// do tracking and capture output
ob_start();
$localTracker = new Tracker();
$localTracker->main($requests);
$output = ob_get_contents();
ob_end_clean();
// restore vars
Config::getInstance()->Tracker = $oldTrackerConfig;
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $oldLang;
$_SERVER['HTTP_USER_AGENT'] = $oldUserAgent;
$_COOKIE = $oldCookie;
$GLOBALS['PIWIK_TRACKER_LOCAL_TRACKING'] = false;
$GLOBALS['PIWIK_TRACKER_MODE'] = false;
unset($_GET['bots']);
// reload plugins
\Piwik\Plugin\Manager::getInstance()->loadPlugins($plugins);
return $output;
}
示例14: set
private function set($name, $value, $config)
{
if ('boolean' == $config['type']) {
$value = $value ? '1' : '0';
} else {
settype($value, $config['type']);
}
Option::set($this->prefix($name), $value);
Cache::clearCacheGeneral();
}
示例15: setUp
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
Tracker\Cache::deleteTrackerCache();
$this->response = new Response();
$this->handler = new Handler();
$this->handler->setResponse($this->response);
$this->tracker = new Tracker();
$this->requestSet = new RequestSet();
}