The following used to work fine:
redis_client.setex(key, expiry_in_sec, value_json)
And now it suddenly returns:
value is not an integer or out of range
The following used to work fine:
redis_client.setex(key, expiry_in_sec, value_json)
And now it suddenly returns:
value is not an integer or out of range
The issue is between the different redis clients.
When working with StrictRedis
, the setex
syntax is:
setex key, expiry, value
When working with Redis
client, the setex
syntax is:
setex key, value, expiry
our specific problem was that someone changed the redis client.
Redis will also return this error if the time value (or expiration time) is a float
instead of an int
.
In my case, using Redis in Python, I had to change the following:
ex = expiration_delta.total_seconds()
ex = int(expiration_delta.total_seconds())
success = redis.set(name=redis_key, value=my_val, ex=ex, nx=True)
Note the ex
argument to set()
makes it work like setex
.
© 2022 - 2024 — McMap. All rights reserved.