Redis-py: What is the difference between StrictRedis () and Redis ()?

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

Also, I cannot find clear documentation on the redis.StrictRedis() arguments in Redis Python Docs . Any idea?

+82
python redis
Sep 26 '13 at 7:17
source share
2 answers

This looks pretty clear :

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

and

 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 

Do you need backward compatibility? Use Redis . Does not care? Use StrictRedis .




2017-03-31

Here are the backward compatibility specifics from the github.com link:

In addition to the changes above, the Redis class, a subclass of StrictRedis, overrides several other commands to provide backward compatibility with older versions of redis-py:

LREM: the order of the arguments 'num' and 'value' is changed so that 'num' can provide a default value of 0.

ZADD: Redis specifies the argument "score" before "value". They were accidentally replaced when they were implemented and were not discovered until people already used it. The Redis class expects * args in the form: name1, score1, name2, score2, ...

SETEX: the arguments "time" and "value" are canceled.




+119
Sep 26 '13 at 9:14
source share

This is an old question, but for those who reach this question after a Google search:

from readme file ( link ):

Redis-Py 3.0 relinquishes support for the legacy Redis client class. StrictRedis has been renamed Redis, and an alias named StrictRedis is provided so that users who previously used StrictRedis can continue to work without change.

Here is a line from Redis-Py code that defines StrictRedis ( link ):

 StrictRedis = Redis 
+15
Apr 7 '19 at 13:11
source share



All Articles