I'm using redis in my python application to store simple values like counters and time stamp lists, but trying to get a counter and comparing it with a number I came across a problem.
If I do:
import redis
...
myserver = redis.Redis("localhost")
myserver.set('counter', 5)
and then try to get that value like this:
if myserver.get('counter') < 10:
myserver.incr('counter')
then I get a type error in the if statement because I'm comparing '5' < 10, which means I'm storing an integer value and getting a string one (which can be considered as a different value).
My question is: is this supposed to work like that? I mean its a very basic type, I understand if I have to parse objects but an int? Seems that I'm doing something wrong.
Is there any configuration I'm missing?
Is there any way to make redis return the right type and not always a string? I say this because its the same for lists and datetimes or even floating point values.
Could this be a problem with the redis-py client I'm using and not redis itself?