Exemplo n.º 1
0
 /**
  * @covers CachedBagOStuff::doGet
  */
 public function testCacheBackendMisses()
 {
     $backend = new HashBagOStuff();
     $cache = new CachedBagOStuff($backend);
     // First hit primes the cache with miss from the backend
     $this->assertEquals(false, $cache->get('foo'));
     // Change the value in the backend
     $backend->set('foo', true);
     // Second hit returns the cached miss
     $this->assertEquals(false, $cache->get('foo'));
     // But a fresh value is read from the backend
     $backend->set('bar', true);
     $this->assertEquals(true, $cache->get('bar'));
 }
Exemplo n.º 2
0
 public function testWriteCacheOnly()
 {
     $backend = new HashBagOStuff();
     $cache = new CachedBagOStuff($backend);
     $cache->set('foo', 'bar', 0, CachedBagOStuff::WRITE_CACHE_ONLY);
     $this->assertEquals('bar', $cache->get('foo'));
     $this->assertFalse($backend->get('foo'));
     $cache->set('foo', 'old');
     $this->assertEquals('old', $cache->get('foo'));
     $this->assertEquals('old', $backend->get('foo'));
     $cache->set('foo', 'new', 0, CachedBagOStuff::WRITE_CACHE_ONLY);
     $this->assertEquals('new', $cache->get('foo'));
     $this->assertEquals('old', $backend->get('foo'));
     $cache->delete('foo', CachedBagOStuff::WRITE_CACHE_ONLY);
     $this->assertEquals('old', $cache->get('foo'));
     // Reloaded from backend
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct(new \HashBagOStuff());
 }