Exemplo n.º 1
0
 /**
  * Function to fetch a cache entry
  *
  * @param string $id The cache entry ID
  * @return array|bool  False on error, or array the cache content
  */
 public function get($id)
 {
     if (empty($id)) {
         return false;
     }
     $id = $this->cleanupId($id);
     if (array_key_exists($id, self::$staticCache)) {
         return self::$staticCache[$id];
     }
     return parent::get($id);
 }
Exemplo n.º 2
0
 /**
  * Load translations for loaded plugins
  *
  * @param bool|string $language Optional language code
  */
 public function loadPluginTranslations($language = false)
 {
     if (empty($language)) {
         $language = Translate::getLanguageToLoad();
     }
     $cache = new CacheFile('tracker', 43200);
     // ttl=12hours
     $cacheKey = 'PluginTranslations';
     if (!empty($language)) {
         $cacheKey .= '-' . trim($language);
     }
     if (!empty($this->loadedPlugins)) {
         // makes sure to create a translation in case loaded plugins change (ie Tests vs Tracker vs UI etc)
         $cacheKey .= '-' . md5(implode('', $this->getLoadedPluginsName()));
     }
     $translations = $cache->get($cacheKey);
     if (!empty($translations) && is_array($translations) && !Development::isEnabled()) {
         Translate::mergeTranslationArray($translations);
         return;
     }
     $translations = array();
     $pluginNames = self::getAllPluginsNames();
     foreach ($pluginNames as $pluginName) {
         if ($this->isPluginLoaded($pluginName) || $this->isPluginBundledWithCore($pluginName)) {
             $this->loadTranslation($pluginName, $language);
             if (isset($GLOBALS['Piwik_translations'][$pluginName])) {
                 $translations[$pluginName] = $GLOBALS['Piwik_translations'][$pluginName];
             }
         }
     }
     $cache->set($cacheKey, $translations);
 }
Exemplo n.º 3
0
 private function assertValueInCache($value)
 {
     $cache = new CacheFile('tracker', 600);
     $siteUrls = $cache->get('allSiteUrlsPerSite');
     $this->assertEquals($value, $siteUrls);
 }
 private function getCachedResult($action, $query)
 {
     $cacheKey = $this->getCacheKey($action, $query);
     return $this->cache->get($cacheKey);
 }