コード例 #1
0
 /**
  * Renders the content with a certain lifetime
  *
  * @param string $key cache key identifier (must be unique per cache entry)
  * @param int $lifetime lifetime of the view part in seconds (0 = default as per page)
  * @param mixed $tags optional tags
  * @param mixed $noCache do not cache if this is non empty
  * @return string
  * @author Maximilian Kalus <*****@*****.**>
  */
 public function render($key, $lifetime = 0, $tags = null, $noCache = null)
 {
     // do not cache if $excludeIfSet not empty
     if (!empty($noCache)) {
         return $this->renderChildren();
     }
     // get cached entry
     $output = static::$cacheInstance->get($key);
     // lifetime of page
     if ($lifetime === 0) {
         $lifetime = intval($GLOBALS['TSFE']->get_cache_timeout());
     }
     // cache miss
     if (!$output || is_null($output)) {
         $output = $this->renderChildren();
         if (!empty($tags)) {
             if (is_string($tags)) {
                 $tags = array($tags);
             }
         } else {
             $tags = array();
         }
         static::$cacheInstance->set($key, $output, $tags, $lifetime);
     }
     return $output;
 }
コード例 #2
0
 /**
  * Interface with the BE user data.
  *
  * @param string $key
  * @return string
  */
 public function render($key)
 {
     $this->initializeCache();
     $key = $this->getModuleLoader()->getDataType() . '_' . $this->getBackendUserIdentifier() . '_' . $key;
     $value = $this->cacheInstance->get($key);
     if ($value) {
         $value = addslashes($value);
     } else {
         $value = '';
     }
     return $value;
 }
コード例 #3
0
 /**
  * Generates an array with terms and hits
  *
  * @return array Tags as array with terms and hits
  */
 protected function getFrequentSearchTerms()
 {
     $terms = array();
     // Use configuration as cache identifier
     $identifier = 'frequentSearchesTags';
     if ($this->configuration['search.']['frequentSearches.']['select.']['checkRootPageId']) {
         $identifier .= '_RP' . (int) $GLOBALS['TSFE']->tmpl->rootLine[0]['uid'];
     }
     if ($this->configuration['search.']['frequentSearches.']['select.']['checkLanguage']) {
         $identifier .= '_L' . (int) $GLOBALS['TSFE']->sys_language_uid;
     }
     $identifier .= '_' . md5(serialize($this->configuration['search.']['frequentSearches.']));
     if ($this->cacheInstance->has($identifier)) {
         $terms = $this->cacheInstance->get($identifier);
     } else {
         $terms = $this->getFrequentSearchTermsFromStatistics();
         if ($this->configuration['search.']['frequentSearches.']['sortBy'] == 'hits') {
             arsort($terms);
         } else {
             ksort($terms);
         }
         $lifetime = null;
         if (isset($this->configuration['search.']['frequentSearches.']['cacheLifetime'])) {
             $lifetime = intval($this->configuration['search.']['frequentSearches.']['cacheLifetime']);
         }
         $this->cacheInstance->set($identifier, $terms, array(), $lifetime);
     }
     return $terms;
 }
コード例 #4
0
 /**
  * Generates an array with terms and hits
  *
  * @return array Tags as array with terms and hits
  */
 public function getFrequentSearchTerms()
 {
     $frequentSearchConfiguration = $this->configuration->getSearchFrequentSearchesConfiguration();
     $terms = array();
     $identifier = $this->getCacheIdentifier($frequentSearchConfiguration);
     if ($this->cache->has($identifier)) {
         $terms = $this->cache->get($identifier);
     } else {
         $terms = $this->getFrequentSearchTermsFromStatistics($frequentSearchConfiguration);
         if ($frequentSearchConfiguration['sortBy'] == 'hits') {
             arsort($terms);
         } else {
             ksort($terms);
         }
         $lifetime = null;
         if (isset($frequentSearchConfiguration['cacheLifetime'])) {
             $lifetime = intval($frequentSearchConfiguration['cacheLifetime']);
         }
         $this->cache->set($identifier, $terms, array(), $lifetime);
     }
     return $terms;
 }
コード例 #5
0
 /**
  * @return void
  */
 public function fakeIdentifierNotInCache()
 {
     $this->cacheMock->expects($this->once())->method('has')->will($this->returnValue(false));
 }