在thinkphp5中将缓存引擎设置为Redis时,会提示报错,Function Redis::delete() is deprecated,原因是因为 redis 弃用了 delete 函数。
可以直接修改 /thinkphp/think/library/cache/driver/Redis.php 第165行:
/**
* 删除缓存
* @access public
* @param string $name 缓存变量名
* @return boolean
*/
public function rm($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->del($key);
}
$this->rm('tag_' . md5($tag));
return true;
}
return $this->handler->flushDB();
}