Redis error: redis.exceptions.ResponseError: value is not an integer or out of range

Problem Description

Today I encountered this error when using python's redis client: redis.exceptions.ResponseError: value is not an integer or out of range, which is a problem when using the setex function.

 

problem analysis

Obviously running well in my development environment, how to get to the test environment is a problem? Then try to read the redis client version of my development environment and test environment, one is 2.x, one is 3.x, the redis client of the test environment is newly installed, then the 3.x is unloaded Install a 2.x, then run ok, it seems to be a version difference. In the purpose of tracking the problem to the end, go to PyPI to find the update document of the redis client. Generally, the big difference in the use is the big version update, directly find the update file of 3.0, and see the following instructions. .

The general idea is that the 3.0 client has abandoned the Redis class and renamed the previous StrictRedis class to Redis. When using the SETEX method, the order of the parameters has changed (name, time, value), no longer the previous one (name , value, time), then what is the difference between the Redis class and the StrictRedis class? as follows:

StrictRedis: used to implement most official commands and use official syntax and commands (for example, the SET command corresponds to the StrictRedis.set method)

Redis: is a subclass of StrictRedis for backward compatibility with older versions of redis-py.

 

Simply put, the official recommendation to use the StrictRedis class, does not recommend the Redis class, because he and we are somewhat different in the redis-cli operation, the main difference is the following three aspects.

1, LREM: The order of the parameters 'num' and 'value' is exchanged, cli is lrem queueName 0 'string', where 0 means all, but Redis this class, the position of 0 and string is changed;

2, ZADD: The order of score and value was accidentally reversed when it was implemented. Later, it was used, and it was like this;

3. The order of SETEX:time and value is reversed.

 

Solution

So there are two solutions, the first one, modify the parameter order of the setex function according to the provisions of 3.x, the second, in exchange for 2.x, of course, the first method is recommended.

 

Reprinted at: https://www.cnblogs.com/lucky-heng/p/11135287.html

Intelligent Recommendation

Redis report error Err value is not an integer or out of ing

How to use the RedisTemplate template when using Spring Boot + RedisredisTemplate.opsForValue().increment(key, 1);This error occurs when you are accumulating. Or sequenceful issues, the solution is to...

Redistemplate+LUA script implementation distributed lock error: @User_Script: 1: Er Value is not an integer or out of range

. Execute LUA script The above script means that if the creation is successful, set the survival time for the current key, and return 1 to 1, and return to 0 if the survival time is successfully set. ...

Mac system Python3 connection Redis error: "redis.exceptions.ResponseError: NOAUTH Authentication required."

Note: Install Redis, Redis library in advance 1.Windows downloads Redis and Redis DesktopManager (visualization tool) in advance and installs it (can be downloaded via github) Redis library  &nbs...

django error redis.exceptions.ResponseError with redis storage session: NOAUTH Authentication required solution

Problem Description I would like to use to store redis session, so I made the following settings in settings.py file: But when I enter the URL in your browser, and executes the stored session that ste...

Resolve redis.exceptions.ResponseError: Please check the Redis logs for details about the RDB error

The problem to be solved today has two main parts:Redis snapshot persistence error, and there is an exception of insufficient server disk. One, Redis snapshot persistence The Redis used in the project...

More Recommendation

MySQL error: Out of range value adjusted for column ...

When I wrote the Mysql stored procedure, I encountered an error like this: Out of range value adjusted for column ... . It is verified that such a fault is caused by the assignment between different t...

MySql error message -out of range value for column

Problem: The ID of a group of data was three digits before, the original type was smallint (5), I thought it was three digits, and I transferred to the tinyint (3) format to save some space. The resul...

MySQL Decimal error (Out of Range Value for Column)

Article catalog Decimal number of pits 1, scene restore 2. Analysis 3, sample demonstration 3.1 Creating a script 3.2 Test Insert Data 3.3 Modify Database Table Field Limit Decimal number of pits 1, s...

SQL error Out of Range Value for Column ‘**‘ at Row

SQL statement error:Out of range valueIt is generally beyond the value range. The field I defined in the database is: But because the score sometimes calculates the negative value exceeding -128, an e...

OpenVSLAM error: x11 error: Badvalue (Integer Parameter Out of Range for Operation)

OpenVSLAM error: x11 error: Badvalue (Integer Parameter Out of Range for Operation) Solution: Perform the following command to drive upgrade and restart (pay attention to save):...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top