简体   繁体   中英

View Commands in Pipeline in Redis-Py?

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)"]

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), {})]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM