Cachearium\CacheData::appendRecursionData PHP Method

appendRecursionData() public method

public appendRecursionData ( CacheData $d )
$d CacheData
    public function appendRecursionData(CacheData $d)
    {
        if (!$d->getKey()) {
            throw new Exceptions\CacheInvalidDataException();
        }
        $this->addDependency($d->getKey());
        $this->data[] = array('type' => self::CACHEDATA_TYPE_RECURSION_DATA, 'data' => $d->getKey());
        return $this;
    }

Usage Example

Example #1
0
 public function testDependencies()
 {
     $cache = Cachearium\Backend\CacheRAM::singleton();
     $ck1 = new CacheKey('recursion', 1, 'sub');
     $ck2 = new CacheKey('recursion', 2, 'sub');
     $ck3 = new CacheKey('recursion', 3, 'sub');
     $cd1 = new CacheData($ck1, 'this');
     $cd2 = new CacheData($ck2, 'is');
     $cd3 = new CacheData($ck3, 'recursion');
     $cd2->appendRecursionData($cd3);
     $cd1->appendRecursionData($cd2);
     $this->assertTrue($cache->storeData($cd3));
     $this->assertTrue($cache->storeData($cd2));
     $this->assertTrue($cache->storeData($cd1));
     $this->assertNotFalse($cache->getData($ck1));
     $this->assertNotFalse($cache->getData($ck2));
     $this->assertNotFalse($cache->getData($ck3));
     $this->assertEquals('thisisrecursion', $cd1->stringify($cache));
     $cd2 = new CacheData($ck2, 'breaks');
     $this->assertTrue($cache->storeData($cd2));
     try {
         $cache->getData($ck1);
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
 }