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


PHP Cache::getEagerCache方法代码示例

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


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

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

示例2: 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 = 'SearchEngine-' . self::OPTION_STORAGE_NAME;
     if ($cache->contains($cacheId)) {
         $list = $cache->fetch($cacheId);
     } else {
         $list = $this->loadDefinitions();
         $cache->save($cacheId, $list);
     }
     return $list;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:17,代码来源:SearchEngine.php

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

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

示例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: 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);
     }
     if (!is_array($list)) {
         Common::printDebug('Warning: could not read list of spammers from cache.');
         return array();
     }
     return $list;
 }
开发者ID:cemo,项目名称:piwik,代码行数:16,代码来源:ReferrerSpamFilter.php

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

示例8: getMapOfModuleActionsToReport

 private static function getMapOfModuleActionsToReport()
 {
     $cacheId = CacheId::pluginAware('ReportFactoryMap');
     $cache = PiwikCache::getEagerCache();
     if ($cache->contains($cacheId)) {
         $mapApiToReport = $cache->fetch($cacheId);
     } else {
         $reports = new static();
         $reports = $reports->getAllReports();
         $mapApiToReport = array();
         foreach ($reports as $report) {
             $key = $report->getModule() . '.' . ucfirst($report->getAction());
             if (isset($mapApiToReport[$key]) && $report->getParameters()) {
                 // sometimes there are multiple reports with same module/action but different parameters.
                 // we might pick the "wrong" one. At some point we should compare all parameters and if there is
                 // a report which parameters mach $_REQUEST then we should prefer that report
                 continue;
             }
             $mapApiToReport[$key] = get_class($report);
         }
         $cache->save($cacheId, $mapApiToReport);
     }
     return $mapApiToReport;
 }
开发者ID:piwik,项目名称:piwik,代码行数:24,代码来源:ReportsProvider.php

示例9: __construct

 public function __construct($ttl = 300)
 {
     $this->ttl = (int) $ttl;
     $this->cache = PiwikCache::getEagerCache();
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:5,代码来源:DeviceDetectorCache.php

示例10: clearInMemoryCaches

 public function clearInMemoryCaches()
 {
     Archive::clearStaticCache();
     DataTableManager::getInstance()->deleteAll();
     Option::clearCache();
     Site::clearCache();
     Cache::deleteTrackerCache();
     PiwikCache::getTransientCache()->flushAll();
     PiwikCache::getEagerCache()->flushAll();
     PiwikCache::getLazyCache()->flushAll();
     ArchiveTableCreator::clear();
     \Piwik\Plugins\ScheduledReports\API::$cache = array();
     Singleton::clearAll();
     PluginsArchiver::$archivers = array();
     $_GET = $_REQUEST = array();
     Translate::reset();
     self::getConfig()->Plugins;
     // make sure Plugins exists in a config object for next tests that use Plugin\Manager
     // since Plugin\Manager uses getFromGlobalConfig which doesn't init the config object
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:20,代码来源:Fixture.php

示例11: getMapOfModuleActionsToReport

 private static function getMapOfModuleActionsToReport()
 {
     $cacheId = CacheId::pluginAware('ReportFactoryMap');
     $cache = Cache::getEagerCache();
     if ($cache->contains($cacheId)) {
         $mapApiToReport = $cache->fetch($cacheId);
     } else {
         $reports = self::getAllReports();
         $mapApiToReport = array();
         foreach ($reports as $report) {
             $key = $report->getModule() . '.' . ucfirst($report->getAction());
             $mapApiToReport[$key] = get_class($report);
         }
         $cache->save($cacheId, $mapApiToReport);
     }
     return $mapApiToReport;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:17,代码来源:Report.php

示例12: loadAvailableLanguages

 private function loadAvailableLanguages()
 {
     if (!is_null($this->availableLanguageNames)) {
         return;
     }
     $cacheId = 'availableLanguages';
     $cache = PiwikCache::getEagerCache();
     if ($cache->contains($cacheId)) {
         $languagesInfo = $cache->fetch($cacheId);
     } else {
         $filenames = $this->getAvailableLanguages();
         $languagesInfo = array();
         foreach ($filenames as $filename) {
             $data = file_get_contents(PIWIK_INCLUDE_PATH . "/lang/{$filename}.json");
             $translations = json_decode($data, true);
             $languagesInfo[] = array('code' => $filename, 'name' => $translations['General']['OriginalLanguageName'], 'english_name' => $translations['General']['EnglishLanguageName']);
         }
         $cache->save($cacheId, $languagesInfo);
     }
     $this->availableLanguageNames = $languagesInfo;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:21,代码来源:API.php

示例13: createCacheIfNeeded

 private function createCacheIfNeeded()
 {
     if (is_null($this->cache)) {
         $this->cache = Cache::getEagerCache();
     }
 }
开发者ID:nuxwin,项目名称:piwik,代码行数:6,代码来源:Plugin.php

示例14: buildCache

 private static function buildCache()
 {
     return PiwikCache::getEagerCache();
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:4,代码来源:SettingsStorage.php

示例15: loadAvailableLanguages

 private function loadAvailableLanguages()
 {
     if (!is_null($this->availableLanguageNames)) {
         return;
     }
     $cacheId = 'availableLanguages';
     $cache = PiwikCache::getEagerCache();
     if ($cache->contains($cacheId)) {
         $languagesInfo = $cache->fetch($cacheId);
     } else {
         $languages = $this->getAvailableLanguages();
         $languagesInfo = array();
         foreach ($languages as $languageCode) {
             $data = @file_get_contents(PIWIK_INCLUDE_PATH . "/plugins/Intl/lang/{$languageCode}.json");
             // Skip languages not having Intl translations
             if (empty($data)) {
                 continue;
             }
             $translations = json_decode($data, true);
             $languagesInfo[] = array('code' => $languageCode, 'name' => $translations['Intl']['OriginalLanguageName'], 'english_name' => $translations['Intl']['EnglishLanguageName']);
         }
         $cache->save($cacheId, $languagesInfo);
     }
     $this->availableLanguageNames = $languagesInfo;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:25,代码来源:API.php


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