pipeline.hget() returns StrictPipeline, NOT value of key
See original GitHub issueI’m unable to use hget on a pipeline to get an actual key value:
red = redis.StrictRedis()
pl = red.pipeline()
ercnt = pl.hget(ecnt,rid)
logging.debug('Got error on action. ercnt="{}"'.format(ercnt))
# => DEBUG Got error on action.
ercnt="StrictPipeline<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>
If I replace above get with:
errcnt=red.hget(ecnt,rid)
I get a value. But I worry that its an unprotected one.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
pipeline.hget() returns StrictPipeline, NOT value of key #563
The HGET doesn't get run until you run pl.execute() , which returns a list of the return values for each command.
Read more >redis.client.StrictPipeline
Return the value at key ``name``, raises a KeyError if the key doesn't exist. ... LPOP a value off of the first non-empty...
Read more >hincrby and hget returning True instead of actual value in ...
I have gone through the documentation and did google but still not able to figure out why hincrby is returning True in the...
Read more >redis.client — TaskFlow documentation
return StrictPipeline ( self.connection_pool, self.response_callbacks, transaction, shard_hint) def transaction(self, func, *watches, ...
Read more >RedPipe Documentation - Read the Docs
RedPipe makes pipeline commands work almost like non-pipelined commands in ... So grabbing the correct value from pipe.execute() is tricky.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You’re on the right track with using WATCH. If you create a pipeline and execute the WATCH command, the pipeline is in a special mode where the commands you run will immediately execute and return until you run
pl.multi(). So you can do something like this:Note that
pl.execute()can raise a WatchError exception. Check out the pipeline section of the redis-py README: https://github.com/andymccurdy/redis-py/blob/master/README.rst#pipelinesI believe the second half of that section is exactly what you’re looking for, along with some convenience optimizations.
Great! I was really confused that why the conditional checks can be used in Redis pipeline. Thanks for your explain on special mode.