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


PHP Option::clearCachedOption方法代码示例

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


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

示例1: getAllSiteIdsToArchive

 public function getAllSiteIdsToArchive()
 {
     Option::clearCachedOption('SharedSiteIdsToArchive');
     $siteIdsToArchive = Option::get('SharedSiteIdsToArchive');
     if (empty($siteIdsToArchive)) {
         return array();
     }
     return explode(',', trim($siteIdsToArchive));
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:9,代码来源:SharedSiteIds.php

示例2: archiveSingleSite

 private function archiveSingleSite($idSite, $requestsBefore)
 {
     $timerWebsite = new Timer();
     $lastTimestampWebsiteProcessedPeriods = $lastTimestampWebsiteProcessedDay = false;
     if ($this->archiveAndRespectTTL) {
         Option::clearCachedOption($this->lastRunKey($idSite, "periods"));
         $lastTimestampWebsiteProcessedPeriods = $this->getPeriodLastProcessedTimestamp($idSite);
         Option::clearCachedOption($this->lastRunKey($idSite, "day"));
         $lastTimestampWebsiteProcessedDay = $this->getDayLastProcessedTimestamp($idSite);
     }
     $this->updateIdSitesInvalidatedOldReports();
     // For period other than days, we only re-process the reports at most
     // 1) every $processPeriodsMaximumEverySeconds
     $secondsSinceLastExecution = time() - $lastTimestampWebsiteProcessedPeriods;
     // if timeout is more than 10 min, we account for a 5 min processing time, and allow trigger 1 min earlier
     if ($this->processPeriodsMaximumEverySeconds > 10 * 60) {
         $secondsSinceLastExecution += 5 * 60;
     }
     $shouldArchivePeriods = $secondsSinceLastExecution > $this->processPeriodsMaximumEverySeconds;
     if (empty($lastTimestampWebsiteProcessedPeriods)) {
         // 2) OR always if script never executed for this website before
         $shouldArchivePeriods = true;
     }
     // (*) If the website is archived because it is a new day in its timezone
     // We make sure all periods are archived, even if there is 0 visit today
     $dayHasEndedMustReprocess = in_array($idSite, $this->websiteDayHasFinishedSinceLastRun);
     if ($dayHasEndedMustReprocess) {
         $shouldArchivePeriods = true;
     }
     // (*) If there was some old reports invalidated for this website
     // we make sure all these old reports are triggered at least once
     $websiteInvalidatedShouldReprocess = $this->isOldReportInvalidatedForWebsite($idSite);
     if ($websiteInvalidatedShouldReprocess) {
         $shouldArchivePeriods = true;
     }
     $websiteIdIsForced = in_array($idSite, $this->shouldArchiveSpecifiedSites);
     if ($websiteIdIsForced) {
         $shouldArchivePeriods = true;
     }
     // Test if we should process this website at all
     $elapsedSinceLastArchiving = time() - $lastTimestampWebsiteProcessedDay;
     // Skip this day archive if last archive was older than TTL
     $existingArchiveIsValid = $elapsedSinceLastArchiving < $this->todayArchiveTimeToLive;
     $skipDayArchive = $existingArchiveIsValid;
     // Invalidate old website forces the archiving for this site
     $skipDayArchive = $skipDayArchive && !$websiteInvalidatedShouldReprocess;
     // Also reprocess when day has ended since last run
     if ($dayHasEndedMustReprocess && !$this->hasBeenProcessedSinceMidnight($idSite, $lastTimestampWebsiteProcessedDay) && !$existingArchiveIsValid) {
         $skipDayArchive = false;
     }
     if ($websiteIdIsForced) {
         $skipDayArchive = false;
     }
     if ($skipDayArchive) {
         $this->logger->info("Skipped website id {$idSite}, already done " . $this->formatter->getPrettyTimeFromSeconds($elapsedSinceLastArchiving, true) . " ago, " . $timerWebsite->__toString());
         $this->skippedDayArchivesWebsites++;
         $this->skipped++;
         return false;
     }
     try {
         $shouldProceed = $this->processArchiveDays($idSite, $lastTimestampWebsiteProcessedDay, $shouldArchivePeriods, $timerWebsite);
     } catch (UnexpectedWebsiteFoundException $e) {
         // this website was deleted in the meantime
         $shouldProceed = false;
         $this->logger->info("Skipped website id {$idSite}, got: UnexpectedWebsiteFoundException, " . $timerWebsite->__toString());
     }
     if (!$shouldProceed) {
         return false;
     }
     if (!$shouldArchivePeriods) {
         $this->logger->info("Skipped website id {$idSite} periods processing, already done " . $this->formatter->getPrettyTimeFromSeconds($elapsedSinceLastArchiving, true) . " ago, " . $timerWebsite->__toString());
         $this->skippedDayArchivesWebsites++;
         $this->skipped++;
         return false;
     }
     $success = $this->processArchiveForPeriods($idSite, $lastTimestampWebsiteProcessedPeriods);
     // Record succesful run of this website's periods archiving
     if ($success) {
         Option::set($this->lastRunKey($idSite, "periods"), time());
     }
     if (!$success) {
         // cancel marking the site as reprocessed
         if ($websiteInvalidatedShouldReprocess) {
             $store = new SitesToReprocessDistributedList();
             $store->add($idSite);
         }
     }
     $this->archivedPeriodsArchivesWebsite++;
     $requestsWebsite = $this->requests - $requestsBefore;
     $this->logger->info("Archived website id = {$idSite}, " . $requestsWebsite . " API requests, " . $timerWebsite->__toString() . " [" . $this->websites->getNumProcessedWebsites() . "/" . $this->websites->getNumSites() . " done]");
     return true;
 }
开发者ID:nuxwin,项目名称:piwik,代码行数:92,代码来源:CronArchive.php

示例3: getWebsiteIdsToInvalidate

 /**
  * Returns array of idSites to force re-process next time core:archive command runs
  *
  * @ignore
  * @return mixed
  */
 public static function getWebsiteIdsToInvalidate()
 {
     Piwik::checkUserHasSomeAdminAccess();
     Option::clearCachedOption(self::OPTION_INVALIDATED_IDSITES);
     $invalidatedIdSites = Option::get(self::OPTION_INVALIDATED_IDSITES);
     if ($invalidatedIdSites && ($invalidatedIdSites = unserialize($invalidatedIdSites)) && count($invalidatedIdSites)) {
         return $invalidatedIdSites;
     }
     return array();
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:16,代码来源:API.php

示例4: assertCustomTasksWereStarted

 private function assertCustomTasksWereStarted()
 {
     Option::clearCachedOption(self::TASKS_STARTED_OPTION_NAME);
     $this->assertEquals(1, Option::get(self::TASKS_STARTED_OPTION_NAME));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:5,代码来源:TrackerTest.php

示例5: getListOptionValue

 protected function getListOptionValue()
 {
     Option::clearCachedOption($this->optionName);
     $array = Option::get($this->optionName);
     $result = array();
     if ($array && ($array = unserialize($array)) && count($array)) {
         $result = $array;
     }
     return $result;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:10,代码来源:DistributedList.php

示例6: getAllSiteIdsToArchive

 public function getAllSiteIdsToArchive()
 {
     Option::clearCachedOption($this->optionName);
     $siteIdsToArchive = Option::get($this->optionName);
     if (empty($siteIdsToArchive)) {
         return array();
     }
     return explode(',', trim($siteIdsToArchive));
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:9,代码来源:SharedSiteIds.php

示例7: archiveSingleSite

 private function archiveSingleSite($idSite, $requestsBefore)
 {
     $timerWebsite = new Timer();
     $lastTimestampWebsiteProcessedPeriods = $lastTimestampWebsiteProcessedDay = false;
     if ($this->archiveAndRespectTTL) {
         Option::clearCachedOption($this->lastRunKey($idSite, "periods"));
         $lastTimestampWebsiteProcessedPeriods = Option::get($this->lastRunKey($idSite, "periods"));
         Option::clearCachedOption($this->lastRunKey($idSite, "day"));
         $lastTimestampWebsiteProcessedDay = Option::get($this->lastRunKey($idSite, "day"));
     }
     $this->updateIdSitesInvalidatedOldReports();
     // For period other than days, we only re-process the reports at most
     // 1) every $processPeriodsMaximumEverySeconds
     $secondsSinceLastExecution = time() - $lastTimestampWebsiteProcessedPeriods;
     // if timeout is more than 10 min, we account for a 5 min processing time, and allow trigger 1 min earlier
     if ($this->processPeriodsMaximumEverySeconds > 10 * 60) {
         $secondsSinceLastExecution += 5 * 60;
     }
     $shouldArchivePeriods = $secondsSinceLastExecution > $this->processPeriodsMaximumEverySeconds;
     if (empty($lastTimestampWebsiteProcessedPeriods)) {
         // 2) OR always if script never executed for this website before
         $shouldArchivePeriods = true;
     }
     // (*) If the website is archived because it is a new day in its timezone
     // We make sure all periods are archived, even if there is 0 visit today
     $dayHasEndedMustReprocess = in_array($idSite, $this->websiteDayHasFinishedSinceLastRun);
     if ($dayHasEndedMustReprocess) {
         $shouldArchivePeriods = true;
     }
     // (*) If there was some old reports invalidated for this website
     // we make sure all these old reports are triggered at least once
     $websiteIsOldDataInvalidate = in_array($idSite, $this->idSitesInvalidatedOldReports);
     if ($websiteIsOldDataInvalidate) {
         $shouldArchivePeriods = true;
     }
     $websiteIdIsForced = in_array($idSite, $this->shouldArchiveSpecifiedSites);
     if ($websiteIdIsForced) {
         $shouldArchivePeriods = true;
     }
     // Test if we should process this website at all
     $elapsedSinceLastArchiving = time() - $lastTimestampWebsiteProcessedDay;
     // Skip this day archive if last archive was older than TTL
     $existingArchiveIsValid = $elapsedSinceLastArchiving < $this->todayArchiveTimeToLive;
     $skipDayArchive = $existingArchiveIsValid;
     // Invalidate old website forces the archiving for this site
     $skipDayArchive = $skipDayArchive && !$websiteIsOldDataInvalidate;
     // Also reprocess when day has ended since last run
     if ($dayHasEndedMustReprocess && !$this->hasBeenProcessedSinceMidnight($idSite, $lastTimestampWebsiteProcessedDay) && !$existingArchiveIsValid) {
         $skipDayArchive = false;
     }
     if ($websiteIdIsForced) {
         $skipDayArchive = false;
     }
     if ($skipDayArchive) {
         $this->log("Skipped website id {$idSite}, already done " . \Piwik\MetricsFormatter::getPrettyTimeFromSeconds($elapsedSinceLastArchiving, true, $isHtml = false) . " ago, " . $timerWebsite->__toString());
         $this->skippedDayArchivesWebsites++;
         $this->skipped++;
         return false;
     }
     // Fake that the request is already done, so that other core:archive commands
     // running do not grab the same website from the queue
     Option::set($this->lastRunKey($idSite, "day"), time());
     // Remove this website from the list of websites to be invalidated
     // since it's now just about to being re-processed, makes sure another running cron archiving process
     // does not archive the same idSite
     if ($websiteIsOldDataInvalidate) {
         $this->setSiteIsArchived($idSite);
     }
     // when some data was purged from this website
     // we make sure we query all previous days/weeks/months
     $processDaysSince = $lastTimestampWebsiteProcessedDay;
     if ($websiteIsOldDataInvalidate || $this->shouldArchiveAllSites) {
         $processDaysSince = false;
     }
     $timer = new Timer();
     $dateLast = $this->getApiDateLastParameter($idSite, "day", $processDaysSince);
     $url = $this->getVisitsRequestUrl($idSite, "day", $dateLast);
     $content = $this->request($url);
     $response = @unserialize($content);
     $visitsToday = $this->getVisitsLastPeriodFromApiResponse($response);
     $visitsLastDays = $this->getVisitsFromApiResponse($response);
     if (empty($content) || !is_array($response) || count($response) == 0) {
         // cancel the succesful run flag
         Option::set($this->lastRunKey($idSite, "day"), 0);
         $this->log("WARNING: Empty or invalid response '{$content}' for website id {$idSite}, " . $timerWebsite->__toString() . ", skipping");
         $this->skipped++;
         return false;
     }
     $this->requests++;
     $this->processed++;
     // If there is no visit today and we don't need to process this website, we can skip remaining archives
     if ($visitsToday == 0 && !$shouldArchivePeriods) {
         $this->log("Skipped website id {$idSite}, no visit today, " . $timerWebsite->__toString());
         $this->skipped++;
         return false;
     }
     if ($visitsLastDays == 0 && !$shouldArchivePeriods && $this->shouldArchiveAllSites) {
         $this->log("Skipped website id {$idSite}, no visits in the last " . $dateLast . " days, " . $timerWebsite->__toString());
         $this->skipped++;
         return false;
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:piwik,代码行数:101,代码来源:CronArchive.php


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