可以在python中查看多个Redis键吗?
我最近一直在玩Redis,想知道如何同时观看多个按键。 下面的东西是原子的吗 下面的代码使用redispy可以在python中查看多个Redis键吗?,python,redis,Python,Redis,我最近一直在玩Redis,想知道如何同时观看多个按键。 下面的东西是原子的吗 下面的代码使用redispy while True: try: pipe.watch(key) pipe.watch(another_key) pipe.multi() pipe.set(key, value) pipe.set(another_key, an
while True:
try:
pipe.watch(key)
pipe.watch(another_key)
pipe.multi()
pipe.set(key, value)
pipe.set(another_key, another_value)
pipe.execute()
break
except redis.WatchError:
continue
finally:
pipe.reset()
redis支持多个键,是: 尽管python客户端的文档说流水线命令是以原子方式执行的,但我仍然会使用带有多个参数的单个
WATCH
调用:
pipe.watch(key, another_key)
哈哈,我已经看了文档至少5次了。好笑的是,我没注意到那些args。