PHP中文网2017-04-25 09:06:06
The atomicity of Redis has two points:
A single operation is atomic
Multiple operations also support transactions, that is, atomicity, wrapped through MULTI
和EXEC
instructions
Atomic operation means that it will either be executed successfully or not executed at all if it fails. The most vivid metaphor is the real-life transfer metaphor. Your transfer either succeeds or fails. The money does not move. There is no such thing as your money being transferred out, but the payee did not receive it. This is a half-success and half-failure situation
Point 1 has been answered
高洛峰2017-04-25 09:06:06
Atomicity: A transaction is an indivisible minimum unit of work, either all succeed or all fail.
Atomic operation means that one of your business logic must be indivisible. For example, if you transfer money to someone else, your account will deduct money, and someone else's account
will add money, this business logic is atomic, and this operation is an atomic operation. , either all succeed or both fail.
The execution of all single commands in Redis is atomic.
The principle of redis implementing transactions
1. 批量操作在发送 EXEC 命令前被放入队列缓存
2. 收到 EXEC 命令后进入事务执行,事务中任意命令执行失败,其余的命令都不会被执行
3. 在事务执行过程,其他客户端提交的命令请求不会插入到事务执行命令序列中
巴扎黑2017-04-25 09:06:06
I feel that atomicity means that only one operation can be performed at the same time. (A transaction is an indivisible minimum unit of work, either all succeed or all fail.) It should be about consistency. I’m a bit confused here