public function test_shared_locals()
 {
     $cacheA = $this->get_cache();
     $cacheB = new LocalCache();
     $cacheA->set('shared_test', 'has a value');
     $cacheA->set('shared_test2', 'exists');
     $keys = ['shared_test', 'shared_test2', 'missing'];
     $resA = $cacheA->get_multi($keys);
     $resB = $cacheB->get_multi($keys);
     $this->assertEmpty(array_diff($keys, array_keys($resA)));
     $this->assertEmpty(array_diff($keys, array_keys($resB)));
     foreach ($resA as $key => $itemA) {
         $itemB = $resB[$key];
         $this->assertEquals($itemA->get_data(), $itemB->get_data());
     }
     $cacheB->delete('shared_test');
     $resA = $cacheA->get_multi($keys);
     $resB = $cacheB->get_multi($keys);
     $this->assertEmpty(array_diff($keys, array_keys($resA)));
     $this->assertEmpty(array_diff($keys, array_keys($resB)));
     foreach ($resA as $key => $itemA) {
         $itemB = $resB[$key];
         $this->assertEquals($itemA->get_data(), $itemB->get_data());
     }
 }
 protected function setUp()
 {
     $local = new LocalCache();
     $local->clear();
     $options = ['servers' => [['host' => 'localhost', 'port' => 11211, 'weight' => 1]], 'prefix' => 'tests/', 'persist' => false, 'ttl' => 1];
     $memcache = new Memcache(true, $options);
     $this->cache = new CacheStack([$local, $memcache]);
 }
Beispiel #3
0
 public function test_disable()
 {
     $this->cache->set_enable(false);
     $this->assertFalse($this->cache->is_enabled());
 }