hincrby and hget returning True instead of actual value in Redis (python)

Tirupati Rao

For performance improvements, I have used the Redis pipeline instead of single insertions. Please find the code snippet for the same.

r = redis.Redis(connection_pool=redis_pool)
r_pipeline = r.pipeline()
for key in keys:
    r_pipeline.hincrby(key, hash, amount)
    r_pipeline.expire(key, Globals.Cache.ttl)
return r_pipeline.execute()

the return value of r_pipeline.execute() is a list. Based on the documentation it supposes to increment and return the incremented value. But sometimes it is actually returning the value and sometimes it is just returning True.

I have gone through the documentation and did google but still not able to figure out why hincrby is returning True in the pipeline.

Can someone please help.

dizzyf

The True is coming from the expire call in the pipeline. In isolation:

>>> p.hincrby('key', 'val', 1)
Pipeline<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>
>>> p.expire('key', 120)
Pipeline<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>
>>> print(p.execute())
[1L, True]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

postman not returning the actual value in console

Is redis HINCRBY atomic?

Redis hgetall or hget?

My serializer is returning index instead of the actual fields

Why is Python returning None instead of value

redis.js get is returning true instead of the value

Function returning a pointer instead of a value in Python

using python and pandas printing index instead of actual value

JSON_VALUE value returning NULL instead of actual value

Python Function is returning none although there is the original Value instead of copy

Returning True if a value is present in an enum; returning false if not

Why is result returning hex instead of actual value?

Returning a true value instead of integer value in prolog

Mysql Coalesce returning 0 instead of actual value

Python bisect: pass value instead of returning insertion index

Redis HINCRBY hash field -1 counter for decrementing only till 0 or non negative value

Storing redis hget values into a variable in nodejs

Python: Finding a substring in a string, but returning True or False instead of the index position

map.get(key) returning true instead of value

How to HGET from multiple hash in redis

WebScraping a date value that appears as January 1970 instead of true value with Python

Function is not returning true value

How to fix Text returning instance of " " instead of the actual value?

Redis is outputting true instead of the desired value

Returning [object Promise] instead of actual value

.str.contains returning actual found value instead of True or False

Why is my code returning the address of the variable instead of the value? (Python)

Why is function returning none instead of the value? (Python)

returning ZoneAwarePromise instead of the actual value in Angular, why?