最近我一直在使用 Redis,想知道如何同时监视多个键。下面的代码是否具有原子性?
以下代码使用 redis-py 库:
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()