예제 #1
0
 /**
  * @code
  * phpunit -v --filter testExpirationCausesNull -c app/ vendor/urodoz/cachemanager/Urodoz/Bundle/CacheBundle/Tests/Service/CacheItem/CacheItemStoreTest.php
  * @endcode
  * @dataProvider providerInmutableDataThroughItem
  */
 public function testExpirationCausesNull($item)
 {
     $cacheItemStore = new CacheItemStore();
     $cacheItemStore->createFromData($item, 0);
     $dataToBeCached = $cacheItemStore->getCacheData();
     $cacheItemStore2 = new CacheItemStore();
     $cacheItemStore2->hydrateFromCacheData($dataToBeCached);
     $this->assertEquals($cacheItemStore2->getData(), null);
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function get($key)
 {
     $key = $this->updateCacheKey($key);
     $result = $this->getActiveImplementation()->get($key);
     //Parse result to retrieve it raw
     if ($result) {
         try {
             $cacheItemStore = new CacheItemStore();
             $cacheItemStore->hydrateFromCacheData($result);
             $cacheItemStore->getData();
             $result = $cacheItemStore->getData();
         } catch (CorruptedDataException $e) {
             $result = null;
         }
     }
     //Throwing event
     if ($result) {
         //Dispatch memcache hit event
         $event = new CacheHitEvent($this->getActiveImplementation()->getName(), $key, $result);
         $this->eventDispatcher->dispatch("urodoz.events.cachehit", $event);
     } else {
         //Dispatch memcache missed hit event
         $event = new MissedCacheHitEvent($this->getActiveImplementation()->getName(), $key);
         $this->eventDispatcher->dispatch("urodoz.events.missed_cachehit", $event);
     }
     return $result;
 }