getData() public method

Same as get, but assumes data was stored with a CacheData object and will treat it accordingly.
public getData ( CacheKey $k ) : CacheData
$k CacheKey
return CacheData
 protected function _callback(CacheAbstract $cache)
 {
     $base = 'callback';
     $key1 = new CacheKey($base, 1);
     $cache->clean($key1);
     $this->assertEquals(CALLBACKVALUE, $cache->startCallback($key1, 'callbackTester'));
     try {
         $data = $cache->getData($key1);
         $this->assertEquals(CALLBACKVALUE, $data->stringify($cache));
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->fail();
     }
 }
Esempio n. 2
0
 private function dependency(CacheAbstract $cache)
 {
     // store
     $key1 = new CacheKey('Namespace', 'Subname');
     $cd = new CacheData($key1, 'xxxx');
     $depkey = new CacheKey('Namespace', 'SomeDep');
     $cd->addDependency($depkey);
     $cache->storeData($cd);
     // check if it is cached
     try {
         $data = $cache->getData($key1);
         $this->assertInstanceOf('Cachearium\\CacheData', $data);
         $this->assertEquals('xxxx', $data->getFirstData());
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->fail();
     }
     // invalidate a dependency
     $cache->invalidate($depkey);
     // get the original and it should be uncached
     try {
         $data = $cache->getData($key1);
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
 }