原文链接:https://blog.csdn.net/xchenhao/article/details/97251618
- PHP 操作 Redis 时遇到如下的问题
PHP Deprecated: Function Redis::delete() is deprecated
PHP Deprecated: Function Redis::lSize() is deprecated
- 原因:php-redis 5 版本弃用了
Redis::delete()
# php --ri redis
运行上述命令看到为 5.0.1 版本
- 解决方法:将
delete($key)
改成del($key)
的操作即可 - 附:被弃用的方法名的解决
被弃用方法名 | 替代方法名 |
---|---|
delete | del |
zUnion | zunionstore |
zInter | zinterstore |
zDeleteRangeByRank | zRemRangeByRank |
zDeleteRangeByScore | zRemRangeByScore |
zDelete | zRem |
setTimeout | expire |
sContains | sismember |
sRemove | srem |
sSize | scard |
lGetRange | lrange |
lGet | lindex |
listTrim | ltrim |
lRemove | lrem |
lSize | lLen |
getKeys | keys |
getMultiple | mget |
renameKey | rename |
- 参考:
- https://www.drupal.org/project/redis/issues/3068810
this is caused by the update to php-redis 5, apparently only in the PHP 7.3 images. 这是由于更新至 php-redis 5 版本后所造成的,很明显只会在 PHP 7.3 出现
- https://github.com/phpredis/phpredis/pull/1588
all aliases are deprecated
&delete is an alias for del
所有的别名被弃用 & delete 之前是作为 del 的别名
- https://pecl.php.net/package-changelog.php?package=redis&release=5.0.0
Soft deprecate methods that aren't actually Redis commands [a81b4f2d, 95c8aab9]
被弃用的方法实际上并不是 Redis 本身自带的命令
- https://github.com/phpredis/phpredis/pull/1572
- https://www.drupal.org/project/redis/issues/3068810
正文完
有偿技术支持加微信