public function getAllSpecializations()
 {
     $key = 'search.widget.controller.specializations.all';
     $data = $this->memcache->get($key);
     if (!$data) {
         $data = $this->searchStrategy->getAllSpecializations();
         $this->memcache->set($key, $data, $this->cacheExpiration);
     }
     return $data;
 }
 /**
  * Generate a memcache key using a configuration key
  * 
  * @param string $key the config memecache key name
  * @param array $memcacheKeyParameters
  * @param array $memcacheNamespaceParameters
  * @throws KeyFactoryException if $key does not exist in MemcacheKeyCollection
  * @author acgvelarde
  */
 public function generate($key, $memcacheKeyParameters = array(), $memcacheNamespaceParameters = array())
 {
     if (!$this->memcacheKeys->has($key)) {
         // key is unrecognizable in our compiled collection
         throw new KeyFactoryException("Cannot generate invalid memcache key {$key}");
     }
     $memcacheKey = $this->memcacheKeys->get($key);
     $tempPattern = $memcacheKey->getPattern();
     // set the pattern to temporary string for manipulation
     // interpolate the variables of the memcache key pattern with $memcacheKeyParameters
     $memcacheKeyString = $this->compiler->interpolatePatternVariables($memcacheKey->getPattern(), $memcacheKey->getVariables(), $memcacheKeyParameters);
     $memcacheNamespaceKeys = array();
     // an array holding the processed memcache namespace patterns
     // prepare the memcache namespaces
     foreach ($memcacheKey->getNamespaces() as $memcacheNamespace) {
         // interpolate the variables in the namespace key regex pattern
         $memcacheNamespaceKeyString = $this->compiler->interpolatePatternVariables($memcacheNamespace->getPattern(), $memcacheNamespace->getVariables(), $memcacheNamespaceParameters);
         // get version of memcache namespace
         $version = $this->memcache->get($memcacheNamespaceKeyString);
         if (!$version) {
             // generate new version for this namespace and save it to memcache
             $version = \time();
             $this->memcache->set($memcacheNamespaceKeyString, $version);
         }
         // append the version to this memcache namespace
         $memcacheNamespaceKeyString .= '_' . $version;
         $memcacheNamespaceKeys[] = $memcacheNamespaceKeyString;
     }
     $memcacheKeyString = $memcacheKeyString . '_' . \implode('_', $memcacheNamespaceKeys);
     // check if this key has been generated and saved to memcache before
     $generatedKeyStorageKey = self::MEMCACHE_GENERATED_KEY_STORAGE_PREFIX . '_' . $memcacheKeyString;
     $storedMemcachekey = $this->memcache->get($generatedKeyStorageKey);
     if (!$storedMemcachekey) {
         // no stored key, let's save this key
         // hash the string so we can have equal lengths of memcache keys
         $memcacheKeyString = SecurityHelper::hash_sha256($memcacheKeyString . time());
         $this->memcache->set($generatedKeyStorageKey, $memcacheKeyString);
     } else {
         $memcacheKeyString = $storedMemcachekey;
     }
     return $memcacheKeyString;
 }
 public function renderSearchResultsImageAd($params = array())
 {
     $memcacheKey = FrontendMemcacheKeys::SEARCH_RESULTS_IMAGE_ADS_KEY;
     $imageAds = $this->memcacheService->get($memcacheKey);
     if (!$imageAds) {
         $ads = $this->retrieverService->getSearchResultsImageAds($params);
         $imageAds = $this->twig->render('AdvertisementBundle:Frontend:imageAd.html.twig', array('imageAds' => $ads));
         $this->memcacheService->set($memcacheKey, $imageAds);
     }
     return $imageAds;
 }
 public function getActiveTreatmentsBySpecialization(Specialization $specialization)
 {
     $key = 'TreatmentBundle:TreatmentService:getActiveTreatmentsBySpecialization_' . $specialization->getId();
     $result = $this->memcache->get($key);
     if (!$result) {
         $result = $this->doctrine->getRepository('TreatmentBundle:Treatment')->getQueryBuilderForActiveTreatmentsBySpecialization($specialization)->getQuery()->getResult();
         // store to memcache
         $this->memcache->set($key, $result);
     }
     return $result;
 }