redis-py:StrictRedis() 和 Redis() 有什么区别? [英] redis-py : What's the difference between StrictRedis() and Redis()?

查看:48
本文介绍了redis-py:StrictRedis() 和 Redis() 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 redis-py 来缓存一些数据,但是我找不到合适的解释 redis.StrictRedis() 之间的区别>redis.Redis().它们是等价的吗?

I want to use redis-py for caching some data, but I can't find a suitable explanation of the difference between redis.StrictRedis() and redis.Redis(). Are they equivalent?

此外,我在 Redis Python 文档.有什么想法吗?

In addition, I can't find any clear documentation about redis.StrictRedis()'s arguments in Redis Python Docs. Any idea?

推荐答案

这看起来很清楚:

 redis-py exposes two client classes that implement these commands
 The StrictRedis class attempts to adhere to the official command syntax.

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

您需要向后兼容吗?使用 Redis.不在乎?使用 StrictRedis.

Do you need backwards compatibility? Use Redis. Don't care? Use StrictRedis.

2017-03-31

这里是向后兼容性的细节,来自引用的 github.com 链接:

Here are the specifics of the backwards compatibility, from the github.com link cited:

除了上述更改之外,Redis 类(StrictRedis 的子类)覆盖了其他几个命令以提供与旧版本 redis-py 的向后兼容性:

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:'num' 和 'value' 参数的顺序颠倒,以便 'num' 可以提供默认值零.

LREM: Order of 'num' and 'value' arguments reversed such that 'num' can provide a default value of zero.

ZADD:Redis 在 'value' 之前指定了 'score' 参数.这些在实施时被意外交换,直到人们已经使用它之后才被发现.Redis 类期望 *args 的形式为:name1, score1, name2, score2, ...

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:'time' 和 'value' 参数的顺序颠倒了.

SETEX: Order of 'time' and 'value' arguments reversed.

这篇关于redis-py:StrictRedis() 和 Redis() 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆