Я использую PHP Memcached &, когда я удаляю ключ, я все равно могу извлечь ключ. Что я могу делать неправильно?Php Memcached delete not working
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"));
После выполнения этого значения все еще возвращает значение. Не уверен, что здесь происходит.
Что такое '$ this -> _ cache [$ key]' и как это связано с memcached? – Cheery
Должен сказать ... Может быть, его кешировали? 8) – Digitalis
Теперь, когда представлено больше кода - 'После выполнения этого, get все равно возвращает значение.' Потому что он берется из '$ this -> _ cache' и вы не очищаете его от' delete'. Или вы имеете в виду новый запрос к скрипту? – Cheery