在redis
中,它说:
A Redis transaction is entered using the MULTI command.
对于其Python
API:
r = redis.Redis(...)
pipe = r.pipeline()
current_value = pipe.get('someKey')
#pipe.multi()
pipe.set('someKey', current_value + 1)
pipe.execute()
有和没有pipe.multi()
的区别是什么?在
为了保证原子性,正确的解决方案是什么?在
Pipelining
是一种机制,可以节省(RTT)往返时间,当您实际想要批量更新/查询密钥时,您不需要为每个密钥单独返回回复。在Multi
实际上将使事务原子化;因此,将一组命令组合成一个命令,example将是:如果有人在事务发生之前或期间查询}。在
foo
的值,他们将得到NULL
,而在事务完成后进行查询的人将得到a,b
,因此您不可能自己得到{Python/redisapi引用默认将其设置为
MULTI
,如果不需要,可以将其设置为false,MULTI/EXEC: These are implemented as part of the Pipeline class. The pipeline is wrapped with the MULTI and EXEC statements by default when it is executed, which can be disabled by specifying transaction=False.
Reference相关问题 更多 >
编程相关推荐