public function isActual($key) { $key = $this->prefix . $key; $flags = 0; $result = $this->instance->get($key, $flags); // $flags stays untouched if $key was not found on the server // @see http://php.net/manual/ru/memcache.get.php#112056 if (empty($result) && empty($flags)) { return false; } return true; }
public function testPrefixesSupported() { $key = 'test'; $fixtureA = 'Hello'; $fixtureB = 'World!'; $configA = $this->config; $configA['prefix'] = 'a'; $configB = $this->config; $configB['prefix'] = 'b'; // Configure::write(Memcache::ConfigurePath, $configA); $instance = new Memcache(); $instance->set($key, $fixtureA); Configure::write(Memcache::ConfigurePath, $configB); $instance = new Memcache(); $instance->set($key, $fixtureB); // Configure::write(Memcache::ConfigurePath, $configA); $instance = new Memcache(); $this->assertEquals($instance->get($key), $fixtureA); // Configure::write(Memcache::ConfigurePath, $configB); $instance = new Memcache(); $this->assertEquals($instance->get($key), $fixtureB); $this->AssertTrue($instance->isActual($key)); $instance->clear($key); $this->AssertFalse($instance->isActual($key)); Configure::write(Memcache::ConfigurePath, $configA); $instance = new Memcache(); $this->assertEquals($instance->get($key), $fixtureA); $this->AssertTrue($instance->isActual($key)); $instance->clear($key); $this->AssertFalse($instance->isActual($key)); }