clear() abstract public method

Clears entire cache. Use sparingly.
abstract public clear ( )
示例#1
0
 public function clear(CacheAbstract $cache)
 {
     $key = new CacheKey('clear', 'it');
     $cd = new CacheData($key, 789);
     $this->assertTrue($cache->storeData($cd));
     $cache->clear();
     try {
         $cache->get($key);
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
 }
示例#2
0
 private function setBigClear(CacheAbstract $cache)
 {
     $id = '2';
     $base = 'bigclean';
     $otherid = '3';
     $otherbase = 'bigfoo';
     $retval = $cache->storeP(111, $base, $id, 'a');
     $this->assertEquals(true, $retval);
     $retval = $cache->storeP(222, $base, $id, 'b');
     $this->assertEquals(true, $retval);
     $retval = $cache->storeP(333, $base, $otherid, 'a');
     $this->assertEquals(true, $retval);
     $retval = $cache->storeP(444, $otherbase, $otherid, 'a');
     $this->assertEquals(true, $retval);
     $data = $cache->getP($base, $id, 'a');
     $this->assertEquals(111, $data);
     $data = $cache->getP($base, $id, 'b');
     $this->assertEquals(222, $data);
     $data = $cache->getP($base, $otherid, 'a');
     $this->assertEquals(333, $data);
     $data = $cache->getP($otherbase, $otherid, 'a');
     $this->assertEquals(444, $data);
     $cache->clear();
     try {
         $data = $cache->getP($base, $id, 'a');
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
     try {
         $data = $cache->getP($base, $id, 'b');
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
     try {
         $data = $cache->getP($base, $otherid, 'a');
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
     try {
         $data = $cache->getP($otherbase, $otherid, 'a');
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
 }