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


PHP Cache::getTransientCache方法代码示例

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


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

示例1: test_isUsedInAtLeastOneSite_shouldCache

 public function test_isUsedInAtLeastOneSite_shouldCache()
 {
     $key = '1.month.' . $this->date;
     $cache = Cache::getTransientCache();
     $this->assertFalse($cache->contains($key));
     $this->userId->isUsedInAtLeastOneSite($idSites = array(1), 'day', $this->date);
     $this->assertTrue($cache->contains($key));
     $this->assertFalse($cache->fetch($key));
 }
开发者ID:cemo,项目名称:piwik,代码行数:9,代码来源:UserIdTest.php

示例2: isUsedInSiteCached

 private function isUsedInSiteCached($idSite, $period, $date)
 {
     $cache = Cache::getTransientCache();
     $key = sprintf('%d.%s.%s', $idSite, $period, $date);
     if (!$cache->contains($key)) {
         $result = $this->isUsedInSite($idSite, $period, $date);
         $cache->save($key, $result);
     }
     return $cache->fetch($key);
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:10,代码来源:UserId.php

示例3: getAvailableLanguageCodes

 /**
  * Returns all language codes the transifex project is available for
  *
  * @return array
  * @throws AuthenticationFailedException
  * @throws Exception
  */
 public function getAvailableLanguageCodes()
 {
     $cache = Cache::getTransientCache();
     $cacheId = 'transifex_languagescodes_' . $this->projectSlug;
     $languageCodes = $cache->fetch($cacheId);
     if (empty($languageCodes)) {
         $apiData = $this->getApiResults('project/' . $this->projectSlug . '/languages');
         foreach ($apiData as $languageData) {
             $languageCodes[] = $languageData->language_code;
         }
         $cache->save($cacheId, $languageCodes);
     }
     return $languageCodes;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:21,代码来源:API.php

示例4: getAllReports

 /**
  * Returns a list of all available reports. Even not enabled reports will be returned. They will be already sorted
  * depending on the order and category of the report.
  * @return \Piwik\Plugin\Report[]
  * @api
  */
 public function getAllReports()
 {
     $reports = $this->getAllReportClasses();
     $cacheId = CacheId::languageAware('Reports' . md5(implode('', $reports)));
     $cache = PiwikCache::getTransientCache();
     if (!$cache->contains($cacheId)) {
         $instances = array();
         /**
          * Triggered to add new reports that cannot be picked up automatically by the platform.
          * This is useful if the plugin allows a user to create reports / dimensions dynamically. For example
          * CustomDimensions or CustomVariables. There are a variable number of dimensions in this case and it
          * wouldn't be really possible to create a report file for one of these dimensions as it is not known
          * how many Custom Dimensions will exist.
          *
          * **Example**
          *
          *     public function addReport(&$reports)
          *     {
          *         $reports[] = new MyCustomReport();
          *     }
          *
          * @param Report[] $reports An array of reports
          */
         Piwik::postEvent('Report.addReports', array(&$instances));
         foreach ($reports as $report) {
             $instances[] = new $report();
         }
         /**
          * Triggered to filter / restrict reports.
          *
          * **Example**
          *
          *     public function filterReports(&$reports)
          *     {
          *         foreach ($reports as $index => $report) {
          *              if ($report->getCategory() === 'Actions') {}
          *                  unset($reports[$index]); // remove all reports having this action
          *              }
          *         }
          *     }
          *
          * @param Report[] $reports An array of reports
          */
         Piwik::postEvent('Report.filterReports', array(&$instances));
         usort($instances, array($this, 'sort'));
         $cache->save($cacheId, $instances);
     }
     return $cache->fetch($cacheId);
 }
开发者ID:piwik,项目名称:piwik,代码行数:55,代码来源:ReportsProvider.php

示例5: setUp

 /**
  * Setup the database and create the base tables for all tests
  */
 public function setUp()
 {
     parent::setUp();
     static::$fixture->extraDefinitions = array_merge(static::provideContainerConfigBeforeClass(), $this->provideContainerConfig());
     static::$fixture->createEnvironmentInstance();
     Db::createDatabaseObject();
     Fixture::loadAllPlugins(new TestingEnvironmentVariables(), get_class($this), self::$fixture->extraPluginsToLoad);
     Access::getInstance()->setSuperUserAccess(true);
     if (!empty(self::$tableData)) {
         self::restoreDbTables(self::$tableData);
     }
     PiwikCache::getEagerCache()->flushAll();
     PiwikCache::getTransientCache()->flushAll();
     MenuAbstract::clearMenus();
 }
开发者ID:hichnik,项目名称:piwik,代码行数:18,代码来源:IntegrationTestCase.php

示例6: test_flushAll_shouldActuallyFlushAllCaches

 public function test_flushAll_shouldActuallyFlushAllCaches()
 {
     $cache1 = Cache::getTransientCache();
     $cache2 = Cache::getLazyCache();
     $cache3 = Cache::getEagerCache();
     $cache1->save('test1', 'content');
     $cache2->save('test2', 'content');
     $cache3->save('test3', 'content');
     $this->assertTrue($cache1->contains('test1'));
     $this->assertTrue($cache2->contains('test2'));
     $this->assertTrue($cache3->contains('test3'));
     Cache::flushAll();
     $this->assertFalse($cache1->contains('test1'));
     $this->assertFalse($cache2->contains('test2'));
     $this->assertFalse($cache3->contains('test3'));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:16,代码来源:CacheTest.php

示例7: getAvailableViewDataTables

 /**
  * Returns all registered visualization classes. Uses the 'Visualization.getAvailable'
  * event to retrieve visualizations.
  *
  * @return array Array mapping visualization IDs with their associated visualization classes.
  * @throws \Exception If a visualization class does not exist or if a duplicate visualization ID
  *                   is found.
  * @return array
  */
 public static function getAvailableViewDataTables()
 {
     $cache = Cache::getTransientCache();
     $cacheId = 'ViewDataTable.getAvailableViewDataTables';
     $dataTables = $cache->fetch($cacheId);
     if (!empty($dataTables)) {
         return $dataTables;
     }
     $klassToExtend = '\\Piwik\\Plugin\\ViewDataTable';
     /** @var string[] $visualizations */
     $visualizations = PluginManager::getInstance()->findMultipleComponents('Visualizations', $klassToExtend);
     /**
      * Triggered when gathering all available DataTable visualizations.
      *
      * Plugins that want to expose new DataTable visualizations should subscribe to
      * this event and add visualization class names to the incoming array.
      *
      * **Example**
      *
      *     public function addViewDataTable(&$visualizations)
      *     {
      *         $visualizations[] = 'Piwik\\Plugins\\MyPlugin\\MyVisualization';
      *     }
      *
      * @param array &$visualizations The array of all available visualizations.
      * @ignore
      * @deprecated since 2.5.0 Place visualization in a "Visualizations" directory instead.
      */
     Piwik::postEvent('ViewDataTable.addViewDataTable', array(&$visualizations));
     $result = array();
     foreach ($visualizations as $viz) {
         if (!class_exists($viz)) {
             throw new \Exception("Invalid visualization class '{$viz}' found in Visualization.getAvailableVisualizations.");
         }
         if (!is_subclass_of($viz, $klassToExtend)) {
             throw new \Exception("ViewDataTable class '{$viz}' does not extend Plugin/ViewDataTable");
         }
         $vizId = $viz::getViewDataTableId();
         if (isset($result[$vizId])) {
             throw new \Exception("ViewDataTable ID '{$vizId}' is already in use!");
         }
         $result[$vizId] = $viz;
     }
     $cache->save($cacheId, $result);
     return $result;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:55,代码来源:Manager.php

示例8: getAvailableViewDataTables

 /**
  * Returns all registered visualization classes. Uses the 'Visualization.getAvailable'
  * event to retrieve visualizations.
  *
  * @return array Array mapping visualization IDs with their associated visualization classes.
  * @throws \Exception If a visualization class does not exist or if a duplicate visualization ID
  *                   is found.
  * @return array
  */
 public static function getAvailableViewDataTables()
 {
     $cache = Cache::getTransientCache();
     $cacheId = 'ViewDataTable.getAvailableViewDataTables';
     $dataTables = $cache->fetch($cacheId);
     if (!empty($dataTables)) {
         return $dataTables;
     }
     $klassToExtend = '\\Piwik\\Plugin\\ViewDataTable';
     /** @var string[] $visualizations */
     $visualizations = PluginManager::getInstance()->findMultipleComponents('Visualizations', $klassToExtend);
     $result = array();
     foreach ($visualizations as $viz) {
         if (!class_exists($viz)) {
             throw new \Exception("Invalid visualization class '{$viz}' found in Visualization.getAvailableVisualizations.");
         }
         if (!is_subclass_of($viz, $klassToExtend)) {
             throw new \Exception("ViewDataTable class '{$viz}' does not extend Plugin/ViewDataTable");
         }
         $vizId = $viz::getViewDataTableId();
         if (isset($result[$vizId])) {
             throw new \Exception("ViewDataTable ID '{$vizId}' is already in use!");
         }
         $result[$vizId] = $viz;
     }
     /**
      * Triggered to filter available DataTable visualizations.
      *
      * Plugins that want to disable certain visualizations should subscribe to
      * this event and remove visualizations from the incoming array.
      *
      * **Example**
      *
      *     public function filterViewDataTable(&$visualizations)
      *     {
      *         unset($visualizations[HtmlTable::ID]);
      *     }
      *
      * @param array &$visualizations An array of all available visualizations indexed by visualization ID.
      * @since Piwik 3.0.0
      */
     Piwik::postEvent('ViewDataTable.filterViewDataTable', array(&$result));
     $cache->save($cacheId, $result);
     return $result;
 }
开发者ID:piwik,项目名称:piwik,代码行数:54,代码来源:Manager.php

示例9: test_getIdSitesToArchiveWhenNoVisits_CanBeUsedToTriggerArchiving_EvenIfSiteHasNoVisits

 public function test_getIdSitesToArchiveWhenNoVisits_CanBeUsedToTriggerArchiving_EvenIfSiteHasNoVisits()
 {
     // add our mock archiver instance
     // TODO: should use a dummy plugin that is activated for this test explicitly, but that can be tricky, especially in the future
     PluginsArchiver::$archivers['VisitsSummary'] = 'Piwik\\Tests\\Integration\\ArchiveWithNoVisitsTest_MockArchiver';
     // initiate archiving w/o adding the event and make sure no methods are called
     VisitsSummaryAPI::getInstance()->get($idSite = 1, 'week', '2012-01-01');
     $this->assertEmpty(ArchiveWithNoVisitsTest_MockArchiver::$methodsCalled);
     // mark our only site as should archive when no visits
     $eventDispatcher = $this->getEventDispatcher();
     $eventDispatcher->addObserver('Archiving.getIdSitesToArchiveWhenNoVisits', function (&$idSites) {
         $idSites[] = 1;
     });
     Cache::getTransientCache()->flushAll();
     // initiate archiving and make sure both aggregate methods are called correctly
     VisitsSummaryAPI::getInstance()->get($idSite = 1, 'week', '2012-01-10');
     $expectedMethodCalls = array('aggregateDayReport', 'aggregateDayReport', 'aggregateDayReport', 'aggregateDayReport', 'aggregateDayReport', 'aggregateDayReport', 'aggregateDayReport', 'aggregateMultipleReports');
     $this->assertEquals($expectedMethodCalls, ArchiveWithNoVisitsTest_MockArchiver::$methodsCalled);
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:19,代码来源:ArchiveWithNoVisitsTest.php

示例10: setUp

 public function setUp()
 {
     Cache::getTransientCache()->flushAll();
     parent::setUp();
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:5,代码来源:BlobReportLimitingTest.php

示例11: getDefaultMetricsDocumentation

 public static function getDefaultMetricsDocumentation()
 {
     $cacheId = CacheId::pluginAware('DefaultMetricsDocumentation');
     $cache = PiwikCache::getTransientCache();
     if ($cache->contains($cacheId)) {
         return $cache->fetch($cacheId);
     }
     $translations = array('nb_visits' => 'General_ColumnNbVisitsDocumentation', 'nb_uniq_visitors' => 'General_ColumnNbUniqVisitorsDocumentation', 'nb_actions' => 'General_ColumnNbActionsDocumentation', 'nb_users' => 'General_ColumnNbUsersDocumentation', 'nb_actions_per_visit' => 'General_ColumnActionsPerVisitDocumentation', 'avg_time_on_site' => 'General_ColumnAvgTimeOnSiteDocumentation', 'bounce_rate' => 'General_ColumnBounceRateDocumentation', 'conversion_rate' => 'General_ColumnConversionRateDocumentation', 'avg_time_on_page' => 'General_ColumnAverageTimeOnPageDocumentation', 'nb_hits' => 'General_ColumnPageviewsDocumentation', 'exit_rate' => 'General_ColumnExitRateDocumentation');
     /**
      * Use this event to register translations for metrics documentation processed by your plugin.
      *
      * @param string[] $translations The array mapping of column_name => Plugin_TranslationForColumnDocumentation
      */
     Piwik::postEvent('Metrics.getDefaultMetricDocumentationTranslations', array(&$translations));
     $translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations);
     $cache->save($cacheId, $translations);
     return $translations;
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:18,代码来源:Metrics.php

示例12: getReportMetadata

 /**
  * Triggers a hook to ask plugins for available Reports.
  * Returns metadata information about each report (category, name, dimension, metrics, etc.)
  *
  * @param string $idSites Comma separated list of website Ids
  * @param bool|string $period
  * @param bool|Date $date
  * @param bool $hideMetricsDoc
  * @param bool $showSubtableReports
  * @return array
  */
 public function getReportMetadata($idSites, $period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false)
 {
     $idSites = Site::getIdSitesFromIdSitesString($idSites);
     if (!empty($idSites)) {
         Piwik::checkUserHasViewAccess($idSites);
     }
     // as they cache key contains a lot of information there would be an even better cache result by caching parts of
     // this huge method separately but that makes it also more complicated. leaving it like this for now.
     $key = $this->buildReportMetadataCacheKey($idSites, $period, $date, $hideMetricsDoc, $showSubtableReports);
     $key = CacheId::pluginAware($key);
     $cache = PiwikCache::getTransientCache();
     if ($cache->contains($key)) {
         return $cache->fetch($key);
     }
     $parameters = array('idSites' => $idSites, 'period' => $period, 'date' => $date);
     $availableReports = array();
     foreach (Report::getAllReports() as $report) {
         $report->configureReportMetadata($availableReports, $parameters);
     }
     /**
      * Triggered when gathering metadata for all available reports.
      *
      * Plugins that define new reports should use this event to make them available in via
      * the metadata API. By doing so, the report will become available in scheduled reports
      * as well as in the Piwik Mobile App. In fact, any third party app that uses the metadata
      * API will automatically have access to the new report.
      *
      * @param string &$availableReports The list of available reports. Append to this list
      *                                  to make a report available.
      *
      *                                  Every element of this array must contain the following
      *                                  information:
      *
      *                                  - **category**: A translated string describing the report's category.
      *                                  - **name**: The translated display title of the report.
      *                                  - **module**: The plugin of the report.
      *                                  - **action**: The API method that serves the report.
      *
      *                                  The following information is optional:
      *
      *                                  - **dimension**: The report's [dimension](/guides/all-about-analytics-data#dimensions) if any.
      *                                  - **metrics**: An array mapping metric names with their display names.
      *                                  - **metricsDocumentation**: An array mapping metric names with their
      *                                                              translated documentation.
      *                                  - **processedMetrics**: The array of metrics in the report that are
      *                                                          calculated using existing metrics. Can be set to
      *                                                          `false` if the report contains no processed
      *                                                          metrics.
      *                                  - **order**: The order of the report in the list of reports
      *                                               with the same category.
      *
      * @param array $parameters Contains the values of the sites and period we are
      *                          getting reports for. Some reports depend on this data.
      *                          For example, Goals reports depend on the site IDs being
      *                          requested. Contains the following information:
      *
      *                          - **idSites**: The array of site IDs we are getting reports for.
      *                          - **period**: The period type, eg, `'day'`, `'week'`, `'month'`,
      *                                        `'year'`, `'range'`.
      *                          - **date**: A string date within the period or a date range, eg,
      *                                      `'2013-01-01'` or `'2012-01-01,2013-01-01'`.
      *
      * TODO: put dimensions section in all about analytics data
      * @deprecated since 2.5.0 Use Report Classes instead.
      * @ignore
      */
     Piwik::postEvent('API.getReportMetadata', array(&$availableReports, $parameters));
     // TODO we can remove this one once we remove API.getReportMetadata event (except hideMetricsDoc)
     foreach ($availableReports as &$availableReport) {
         // can be removed once we remove hook API.getReportMetadata
         if (!isset($availableReport['metrics'])) {
             $availableReport['metrics'] = Metrics::getDefaultMetrics();
         }
         // can be removed once we remove hook API.getReportMetadata
         if (!isset($availableReport['processedMetrics'])) {
             $availableReport['processedMetrics'] = Metrics::getDefaultProcessedMetrics();
         }
         if ($hideMetricsDoc) {
             unset($availableReport['metricsDocumentation']);
         } else {
             if (!isset($availableReport['metricsDocumentation'])) {
                 // set metric documentation to default if it's not set
                 // can be removed once we remove hook API.getReportMetadata
                 $availableReport['metricsDocumentation'] = Metrics::getDefaultMetricsDocumentation();
             }
         }
     }
     /**
      * Triggered after all available reports are collected.
//.........这里部分代码省略.........
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:101,代码来源:ProcessedReport.php

示例13: getAllReports

 /**
  * Returns a list of all available reports. Even not enabled reports will be returned. They will be already sorted
  * depending on the order and category of the report.
  * @return \Piwik\Plugin\Report[]
  * @api
  */
 public static function getAllReports()
 {
     $reports = self::getAllReportClasses();
     $cacheId = CacheId::languageAware('Reports' . md5(implode('', $reports)));
     $cache = PiwikCache::getTransientCache();
     if (!$cache->contains($cacheId)) {
         $instances = array();
         foreach ($reports as $report) {
             $instances[] = new $report();
         }
         usort($instances, array('self', 'sort'));
         $cache->save($cacheId, $instances);
     }
     return $cache->fetch($cacheId);
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:21,代码来源:Report.php

示例14: getSocialUrls

 /**
  * Returns list of social networks by URL
  *
  * @see core/DataFiles/Socials.php
  *
  * @return array  Array of ( URL => Social Network Name )
  */
 public static function getSocialUrls()
 {
     $cacheId = 'Common.getSocialUrls';
     $cache = Cache::getTransientCache();
     $socialUrls = $cache->fetch($cacheId);
     if (empty($socialUrls)) {
         require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Socials.php';
         $socialUrls = $GLOBALS['Piwik_socialUrl'];
         Piwik::postEvent('Referrer.addSocialUrls', array(&$socialUrls));
         $cache->save($cacheId, $socialUrls);
     }
     return $socialUrls;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:20,代码来源:Common.php

示例15: isIpInRange

 private function isIpInRange()
 {
     $cache = PiwikCache::getTransientCache();
     $ip = IP::fromBinaryIP($this->ip);
     $key = 'VisitExcludedIsIpInRange' . $ip->toString();
     if ($cache->contains($key)) {
         $isInRanges = $cache->fetch($key);
     } else {
         if ($this->isChromeDataSaverUsed($ip)) {
             $isInRanges = false;
         } else {
             $isInRanges = $ip->isInRanges($this->getBotIpRanges());
         }
         $cache->save($key, $isInRanges);
     }
     return $isInRanges;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:17,代码来源:VisitExcluded.php


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