Пример #1
0
 public function __construct(Backend $backend, $scopeName)
 {
     // The prefix we pass along to the Prefix() constructor is never used, so
     // it doesn't matter.
     parent::__construct($backend, null);
     $this->scopeName = $scopeName;
     $this->backend = $backend;
 }
Пример #2
0
 public function testPrefix()
 {
     $memoryCache = new Matryoshka\Ephemeral();
     $prefix = 'prefix';
     $prefixedCache = new Matryoshka\Prefix($memoryCache, $prefix);
     list($key, $value) = $this->getRandomKeyValue();
     $this->assertNull($prefixedCache->get($key));
     $this->assertTrue($prefixedCache->set($key, $value));
     $this->assertSame($value, $prefixedCache->get($key));
     $this->assertSame($value, $memoryCache->get("{$prefix}{$key}"));
     $this->assertNull($memoryCache->get($key));
     $this->assertTrue($prefixedCache->delete($key));
     $this->assertNull($prefixedCache->get($key));
     $this->assertNull($memoryCache->get("{$prefix}{$key}"));
     $this->assertNull($memoryCache->get($key));
 }