Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis - Error: value is not a valid float

I have a sorted set in Redis. I am trying to update the counter value of a specific element by using zincrby in Python code like:

conn.zincrby("usersSet", float(1), "user1")

But it is showing an error as : 'Error: value is not a valid float'

I tried the same command on cli : zincrby usersSet 1 users1 And it is working correctly. Is there any other method in Python code to increase the counter value of the specific key in the sorted set.

like image 515
Swapnil Avatar asked Jan 29 '23 06:01

Swapnil


1 Answers

Parameters order are differ between redis-cli and python connector. You have to write conn.zincrby("usersSet", "user1", 1)

UPDATE

The python redis library was updated to match redis-cli's order of arguments.

Hence, conn.zincrby("usersSet", 1, "user1") will be the correct usage now.

like image 185
Vadim Kharitonov Avatar answered Jan 30 '23 18:01

Vadim Kharitonov