Redis transactions

The four properties of a transaction are known as ACID: atomicity; consistency; Isolation, 4. Persistence.

They are defined as follows:

1. Atomicity: A transaction is the smallest unit of program execution, in which all commands are executed at once or none at all (if one command fails, all commands fail). 2. Consistency: The data remains consistent before and after the transaction is executed, and all things read the same data. 3. Isolation: Transactions are not visible to other transactions until committed. 4. Persistence: Once a transaction is committed, the data is kept forever, even if the system crashes.

Since Redis transactions do not support rollback, many people say that therefore Redis transactions are not atomic, really? Take a look at the official document:

Redis. IO/switchable viewer/tran…

Either all of the commands or none are processed, so a Redis transaction is also atomic.

Because part of it satisfies the definition of atomicity, either the instructions in the transaction execute together or none at all.

So Redis transactions are atomic, or as atomic as they think they are. Note, however, that if one command in a Redis transaction fails to execute, the other commands will execute as usual.

Redis transactions are segregated.

Redis persistence guarantees partial persistence.

Redis transactions do not satisfy consistency. Consistency is the consistency of data before and after a transaction is executed, and Redis does not support rollback.

reference

Redis. IO/switchable viewer/tran…