PHP Memcached删除功能无法按预期工作

时间:2016-01-26 20:58:38

标签: php memcached

所以问题是我想从memcached中删除的键实际上没有被删除。我没有错。在这一点上,我真的不知道问题可能是什么。它还显示了要删除的正确密钥,因此没有任何问题。

在我的Class下面使用memcached,有没有人知道问题可能是什么?到目前为止,我没有找到问题可能是什么或如何解决问题的线索。

class MemCacher extends Memcached{


function __construct(){
    parent::__construct();
    parent::addServer(MEMCACHED_SERVER,11211,1);

}

function add($p_sKey,$p_oData,$p_iTime = 43200){
    $t_sKey = CACHE_NAME.$p_sKey;
    parent::set($t_sKey,$p_oData,$p_iTime);
}

function get($p_sKey){
    $t_sKey = CACHE_NAME.$p_sKey;
    return parent::get($t_sKey);
}

function remove($p_sKey){
    $t_sKey = CACHE_NAME.$p_sKey;
    parent::delete($t_sKey);
    debug("Deleted:".$t_sKey);
}

function show_all(){
    if( $l_aCacheInfo = parent::getAllKeys() ){
        foreach($l_aCacheInfo as $key){
            if( strpos($key, CACHE_NAME) !== FALSE ){
                debug($key);
            }
        }
    }   
}

function clear_all(){

    if( $l_aCacheInfo = parent::getAllKeys() ){
        foreach($l_aCacheInfo as $key){
            if( strpos($key, CACHE_NAME) !== FALSE ){
               parent::delete($key);
               debug("Deleted:".$key);
            }
        }
    }   
}

}

1 个答案:

答案 0 :(得分:0)

显然,删除方法要求过期时间为0才能删除它,否则它不起作用。

不起作用

parent::delete($t_sKey);

作品

parent::delete($t_sKey,0);