我使用PHP Memcached &当我删除一个密钥时,我仍然可以检索密钥。我可能做错了什么?Php Memcached删除不起作用
function __construct() {
$this->_cache = array();
// if we have memcache support, load it from CACHE_POOL
//
if (class_exists('Memcached')) {
$this->_mc = new Memcached('CACHE_POOL');
$servers = $this->_mc->getServerList();
if (empty($servers)) {
//This code block will only execute if we are setting up a new EG(persistent_list) entry
$this->_mc->setOption(Memcached::OPT_RECV_TIMEOUT, 1000);
$this->_mc->setOption(Memcached::OPT_SEND_TIMEOUT, 3000);
$this->_mc->setOption(Memcached::OPT_TCP_NODELAY, true);
$this->_mc->setOption(Memcached::OPT_PREFIX_KEY, "md_");
$this->_mc->addServers(self::$_MEMCACHE_IPS);
}
$current_cache = $this->_mc->get(self::CACHE_KEY);
if ($current_cache) {
$this->_cache = array_merge($this->_cache, $current_cache);
}
}
}
function delete($key) {
self::instance()->_mc->delete($key);
}
function getSafe($key) {
return isset($this->_cache[$key]) ? $this->_cache[$key] : FALSE;
}
self::instance()->delete("test");
echo(self::instance()->getSafe("test"));
运行后,get仍返回一个值。不知道这里发生了什么。
什么是'$ this - > _cache [$ key]',它与memcached有什么关系? – Cheery 2014-11-04 00:56:21
要说......也许它的缓存? 8) – Digitalis 2014-11-04 01:03:53
现在,当提供更多代码时:'运行此代码后,get仍返回一个值,因为它取自'$ this - > _ cache',并且您没有在delete中清除它。或者你的意思是在对剧本的新要求中? – Cheery 2014-11-04 01:23:29