Exemplo n.º 1
0
 public function testLocalGetMultipleOptimizeOnEmpty()
 {
     $ephemeral = new Matryoshka\Ephemeral();
     $stats = new Matryoshka\Stats($ephemeral);
     $cache = new TestLocal($stats);
     list($key, $value) = $this->getRandomKeyValue();
     $ephemeral->set($key, $value);
     list($found, $missing) = $cache->getMultiple([$key => 'key']);
     $getMultiCount = $stats->getStats()['getMultiple_count'];
     list($found, $missing) = $cache->getMultiple([$key => 'key']);
     // Assert that "Local" cache hits don't end up querying the underlying backend at all
     $this->assertSame($getMultiCount, $stats->getStats()['getMultiple_count']);
 }
Exemplo n.º 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));
 }
Exemplo n.º 3
0
 public function increment($key, $amount = 1, $expiration = 0)
 {
     $this->lastExpiration = $expiration;
     return parent::increment($key, $amount, $expiration);
 }