/**
  * 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;
 }