View commands in Pipeline in Redis-Py?

Is there an easy way to just view the commands that have been queued in the pipeline in Redis-Py? I can't find anything in the documentation about this, but it seems like a trivial and useful command. I 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)"] 
+4
source share
1 answer

You can check 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), {})] 
+5
source

Source: https://habr.com/ru/post/1488774/


All Articles