public function getMetrics($domain)
 {
     $cacheId = 'SEO_getRank_' . md5($domain);
     $metrics = $this->cache->fetch($cacheId);
     if (!is_array($metrics)) {
         $metrics = $this->provider->getMetrics($domain);
         $this->cache->save($cacheId, $metrics, 60 * 60 * 6);
     }
     return $metrics;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function load($language, array $directories)
 {
     if (empty($language)) {
         return array();
     }
     $cacheKey = $this->getCacheKey($language, $directories);
     $translations = $this->cache->fetch($cacheKey);
     if (empty($translations) || !is_array($translations)) {
         $translations = $this->loader->load($language, $directories);
         $this->cache->save($cacheKey, $translations, 43200);
         // ttl=12hours
     }
     return $translations;
 }
Example #3
0
File: Cache.php Project: cemo/piwik
 /**
  * @param $valueToMatch
  * @param $sql
  * @return array of IDs, or null if the returnset is too big to cache
  */
 private function getIdsFromCache($valueToMatch, $sql)
 {
     $cacheKey = $this->getCacheKey($valueToMatch, $sql);
     if ($this->cache->contains($cacheKey) === true) {
         // TODO: hits
         $this->logger->debug("Segment subquery cache HIT (for '{$valueToMatch}' and SQL '{$sql})");
         return $this->cache->fetch($cacheKey);
     }
     $ids = $this->fetchActionIdsFromDb($valueToMatch, $sql);
     if ($this->isTooBigToCache($ids)) {
         $this->logger->debug("Segment subquery cache SKIPPED SAVE (too many IDs returned by subquery: %s ids)'", array(count($ids)));
         $this->cache->save($cacheKey, $ids = null, $this->lifetime);
         return null;
     }
     $this->cache->save($cacheKey, $ids, $this->lifetime);
     $this->logger->debug("Segment subquery cache SAVE (for '{$valueToMatch}' and SQL '{$sql}')'");
     return $ids;
 }
Example #4
0
 public function clearAllCacheEntries()
 {
     $this->cache->flushAll();
 }