Is there a simple way to just view the commands that have been queued up in a pipeline in Redis-Py? I can't find anything in the documentation about this, but it seems like a trivial and useful command. I'd just want to do something like:
p = redis_conn.pipeline()
p.hset('blah', 'meh', 1)
p.hset('foo', 'bar', 1)
print p.view() #returns ["hset('blah', 'meh', 1)", "hset('foo', 'bar', 1)"]
Redis pipelining is a technique for improving performance by issuing multiple commands at once without waiting for the response to each individual command. Pipelining is supported by most Redis clients. This document describes the problem that pipelining is designed to solve and how pipelining works in Redis.
Redis server connection can be checked by executing ping command to the server. using the ping method, we can handle reconnection etc. For knowing the reason for error in connecting, exception handling can be used as suggested in other answers.
You can inspect the command_stack
:
In [17]: p.hset('blah', 'meh', 1)
Out[17]: <redis.client.StrictPipeline at 0x10d4dde90>
In [18]: p.hset('foo', 'bar', 1)
Out[18]: <redis.client.StrictPipeline at 0x10d4dde90>
In [19]: p.command_stack
Out[19]: [(('HSET', 'blah', 'meh', 1), {}), (('HSET', 'foo', 'bar', 1), {})]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With