我想使用Redis的-PY缓存一些数据,但我无法找到之间的差异的一个合适的解释redis.StrictRedis()和redis.Redis().它们是等价的吗?
另外,我redis.StrictRedis()在Redis Python Docs中找不到关于参数的任何明确文档.任何的想法?
hug*_*own 122
redis-py exposes two client classes that implement these commands
The StrictRedis class attempts to adhere to the official command syntax.
Run Code Online (Sandbox Code Playgroud)
和
In addition to the changes above, the Redis class, a subclass of StrictRedis,
overrides several other commands to provide backwards compatibility with older
versions of redis-py
Run Code Online (Sandbox Code Playgroud)
你需要向后兼容吗?使用Redis.不在乎?使用StrictRedis.
2017年3月31日
以下是向后兼容性的细节,来自引用的github.com链接:
除了上面的更改之外,Redis类(StrictRedis的子类)会覆盖其他几个命令,以提供与旧版本redis-py的向后兼容性:
LREM:'num'和'value'参数的顺序颠倒过来,'num'可以提供默认值零.
ZADD:Redis在'value'之前指定'score'参数.这些在实施时被意外交换,直到人们已经使用它之后才被发现.Redis类期望*args的形式为:name1,score1,name2,score2,...
SETEX:'时间'和'价值'参数的顺序颠倒了.
ali*_*iva 21
这是一个老问题,但对于在Google搜索后遇到此问题的任何人:
从redis-py自述文件(链接):
redis-py 3.0放弃了对旧版“ Redis”客户端类的支持。“ StrictRedis”已重命名为“ Redis”,并提供了一个名为“ StrictRedis”的别名,以便以前使用“ StrictRedis”的用户可以继续运行。
这是定义StrictRedis(link)的redis-py代码的代码:
StrictRedis = Redis
Run Code Online (Sandbox Code Playgroud)