Redis的API和StrictRedis有什么区别?
What's the difference between the API of Redis and StrictRedis?
我正在使用 redis.py 开发一个项目,我在将应用程序连接到 Redis 客户端时工作,但使用 StrictRedis 时失败了。
所以,我想知道两者之间的区别,但搜索没有满意的答案。
我的项目在这里:https://github.com/kxxoling/librorum中文注释不好意思!
来自 redis-py README:
The official Redis command documentation does a great job of explaining each command in detail. redis-py exposes two client classes that implement these commands.
The StrictRedis class attempts to adhere to the official command syntax.
StrictRedis 还具有无 向后兼容性:
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:
LREM
: Order of num
and value
arguments reversed such that 'num'
can provide a default value of zero.
ZADD
: Redis specifies the
score
argument before value
. These were swapped accidentally when
being implemented and not discovered until after people were already
using it. The Redis class expects *args
in the form of: name1
,
score1
, name2
, score2
, ...
SETEX
: Order of time
and
value
arguments reversed.
因此,如果您长期使用 redis-py
,您应该坚持使用 Redis
class - 它已将一些命令的参数顺序更改为看起来更像 Pythonic(甚至通过事故)。
在源代码 (client.py:class Redis) 中,您可以看到更改的内容。
我正在使用 redis.py 开发一个项目,我在将应用程序连接到 Redis 客户端时工作,但使用 StrictRedis 时失败了。
所以,我想知道两者之间的区别,但搜索没有满意的答案。
我的项目在这里:https://github.com/kxxoling/librorum中文注释不好意思!
来自 redis-py README:
The official Redis command documentation does a great job of explaining each command in detail. redis-py exposes two client classes that implement these commands.
The StrictRedis class attempts to adhere to the official command syntax.
StrictRedis 还具有无 向后兼容性:
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:
LREM
: Order ofnum
andvalue
arguments reversed such that 'num' can provide a default value of zero.ZADD
: Redis specifies thescore
argument beforevalue
. These were swapped accidentally when being implemented and not discovered until after people were already using it. The Redis class expects*args
in the form of:name1
,score1
,name2
,score2
, ...SETEX
: Order oftime
andvalue
arguments reversed.
因此,如果您长期使用 redis-py
,您应该坚持使用 Redis
class - 它已将一些命令的参数顺序更改为看起来更像 Pythonic(甚至通过事故)。
在源代码 (client.py:class Redis) 中,您可以看到更改的内容。