pipelining vs transaction in redis

不想你离开。 提交于 2019-12-29 03:13:11

问题


When we use a transaction in Redis, it basically pipelines all the commands within the transaction. And when EXEC is fired, then all the commands are executed together, thus always maintaining the atomicity of multiple commands.

Isn't this same as pipelining?

How are pipelining and transaction different? Also, why does not the single threaded nature of Redis suffice? Why do we explicitly need pipelining/transaction?


回答1:


Pipelining is primarily a network optimization. It essentially means the client buffers up a bunch of commands and ships them to the server in one go. The commands are not guaranteed to be executed in a transaction. The benefit here is saving network round trip time for every command.

Redis is single threaded so an individual command is always atomic, but two given commands from different clients can execute in sequence, alternating between them for example.

Multi/exec, however, ensures no other clients are executing commands in between the commands in the multi/exec sequence.



来源:https://stackoverflow.com/questions/29327544/pipelining-vs-transaction-in-redis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!