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


PHP Piwik\Cache类代码示例

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


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     PiwikCache::flushAll();
     Translate::loadAllTranslations();
     $this->api = API::getInstance();
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:7,代码来源:ApiTest.php

示例2: getCache

 /**
  * @return \Piwik\Cache\Lazy
  */
 private static function getCache()
 {
     if (is_null(self::$cache)) {
         self::$cache = PiwikCache::getLazyCache();
     }
     return self::$cache;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:10,代码来源:Cache.php

示例3: loadTrackerPlugins

 /**
  * @return array names of plugins that have been loaded
  */
 public function loadTrackerPlugins()
 {
     $cacheId = 'PluginsTracker';
     $cache = Cache::getEagerCache();
     if ($cache->contains($cacheId)) {
         $pluginsTracker = $cache->fetch($cacheId);
     } else {
         $this->unloadPlugins();
         $this->loadActivatedPlugins();
         $pluginsTracker = array();
         foreach ($this->loadedPlugins as $pluginName => $plugin) {
             if ($this->isTrackerPlugin($plugin)) {
                 $pluginsTracker[] = $pluginName;
             }
         }
         if (!empty($pluginsTracker)) {
             $cache->save($cacheId, $pluginsTracker);
         }
     }
     if (empty($pluginsTracker)) {
         $this->unloadPlugins();
         return array();
     }
     $pluginsTracker = array_diff($pluginsTracker, $this->getTrackerPluginsNotToLoad());
     $this->doNotLoadAlwaysActivatedPlugins();
     $this->loadPlugins($pluginsTracker);
     // we could simply unload all plugins first before loading plugins but this way it is much faster
     // since we won't have to create each plugin again and we won't have to parse each plugin metadata file
     // again etc
     $this->makeSureOnlyActivatedPluginsAreLoaded();
     return $pluginsTracker;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:35,代码来源:Manager.php

示例4: test_onSiteDeleted_shouldClearSiteCache

 public function test_onSiteDeleted_shouldClearSiteCache()
 {
     $cache = Cache::getLazyCache();
     $cache->save($this->siteId, 'testcontent');
     $this->manager->onSiteDeleted($this->siteId);
     $this->assertFalse($cache->contains($this->siteId));
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:7,代码来源:SitesManagerTest.php

示例5: 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();
     TrackerCache::deleteTrackerCache();
     PiwikCache::flushAll();
     self::clearPhpCaches();
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:12,代码来源:Filesystem.php

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

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

示例8: getDefinitions

 /**
  * Returns list of search engines by URL
  *
  * @return array  Array of ( URL => array( searchEngineName, keywordParameter, path, charset ) )
  */
 public function getDefinitions()
 {
     $cache = Cache::getEagerCache();
     $cacheId = 'Social-' . self::OPTION_STORAGE_NAME;
     if ($cache->contains($cacheId)) {
         $list = $cache->fetch($cacheId);
     } else {
         $list = $this->loadDefinitions();
         $cache->save($cacheId, $list);
     }
     return $list;
 }
开发者ID:JoeHorn,项目名称:piwik,代码行数:17,代码来源:Social.php

示例9: getSpammerListFromCache

 private function getSpammerListFromCache()
 {
     $cache = Cache::getEagerCache();
     $cacheId = 'ReferrerSpamFilter-' . self::OPTION_STORAGE_NAME;
     if ($cache->contains($cacheId)) {
         $list = $cache->fetch($cacheId);
     } else {
         $list = $this->loadSpammerList();
         $cache->save($cacheId, $list);
     }
     return $list;
 }
开发者ID:GovanifY,项目名称:piwik,代码行数:12,代码来源:ReferrerSpamFilter.php

示例10: test_getEagerCache_shouldPersistOnceEventWasTriggered

 public function test_getEagerCache_shouldPersistOnceEventWasTriggered()
 {
     $storageId = 'eagercache-test-ui';
     $cache = Cache::getEagerCache();
     $cache->save('test', 'mycontent');
     // make sure something was changed, otherwise it won't save anything
     /** @var Cache\Backend $backend */
     $backend = StaticContainer::get('Piwik\\Cache\\Backend');
     $this->assertFalse($backend->doContains($storageId));
     Piwik::postEvent('Request.dispatch.end');
     // should trigger save
     $this->assertTrue($backend->doContains($storageId));
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:13,代码来源:CacheTest.php

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

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

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

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     // make sure templates will be found
     Plugin\Manager::getInstance()->loadPlugin('CustomAlerts');
     Plugin\Manager::getInstance()->loadPlugin('Morpheus');
     if (class_exists('\\Piwik\\Cache\\PluginAwareStaticCache')) {
         \Piwik\Cache\PluginAwareStaticCache::clearAll();
         // TODO remove this one
     } else {
         PiwikCache::flushAll();
     }
     Translate::loadAllTranslations();
     $this->controller = new CustomController();
 }
开发者ID:andrzejewsky,项目名称:plugin-CustomAlerts,代码行数:15,代码来源:ControllerTest.php

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


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