Theoretical knowledge:
Redis is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of key/value storage such as memcached, and can play a very good supplementary role to relational databases in some situations. It provides Java, C/C, C#, PHP, JavaScript, Perl, Object-C, Python, Ruby, Erlang and other clients, which is very convenient to use.
Atomicity (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 successful or failed.
The execution of all single commands in Redis is atomic.
The principle of redis transaction implementation
1. Batch operations are put into the queue cache before sending the EXEC command
2. Received Enter transaction execution after the EXEC command. If any command in the transaction fails to execute, the remaining commands will not be executed.
3. During the transaction execution process, command requests submitted by other clients will not be inserted into the transaction execution command sequence. middle
The above is the detailed content of Does redis support atomic operations?. For more information, please follow other related articles on the PHP Chinese website!