php redis del函数,THINKPHP5报错 Function Redis::delete() is deprecated解决方法
“Function Redis::delete() is deprecated”从字面理解就是Redis缓存的delete()函数被弃用了。这个问题一般只出现在新版本的php-redis插件中,旧版本不影响。
解决方法:将 delete($key) 改成 del($key) 的操作,或者切换PHP版本即可。
如果在此之前你采用的是TP5框架的,可以直接修改/thinkphp/library/cache/driver/redis.php第156行。
/**
* 删除缓存
* @access public
* @param string $name 缓存变量名
* @return boolean
*/
public function rm($name)
{
//return $this->handler->delete($this->getCacheKey($name));
return $this->handler->del($this->getCacheKey($name));
}
/**
* 清除缓存
* @access public
* @param string $tag 标签名
* @return boolean
*/
public function clear($tag = null)
{
if ($tag) {
// 指定标签清除
$keys = $this->getTagItem($tag);
foreach ($keys as $key) {
//$this->handler->delete($key);
$this->handler->del($key);
}
$this->rm('tag_' . md5($tag));
return true;
}
return $this->handler->flushDB();
}
拓展:被弃用的其他函数及替代函数。

更多推荐


所有评论(0)