Redis is an open source log-type Key-Value database written in ANSI C language, supports network, can be memory-based and persistent, and provides APIs in multiple languages.
Atomicity
Atomicity is a characteristic of database transactions. In the context of database transactions, atomicity refers to: all operations in a transaction (transaction) are either completely completed or not completed, and will not end somewhere in the middle.
For Redis, the atomicity of a command means that an operation cannot be subdivided, and the operation is either executed or not.
The reason why Redis operations are atomic
The reason why Redis operations are atomic is because Redis is single-threaded.
Since I am not very familiar with operating system-related knowledge, I cannot really understand the reason why Redis operations are atomic from the above sentence. Please further check the concepts and differences between processes and threads.
The performance of Redis in concurrency
The API of Redis is an atomic operation, so are multiple commands also atomic in concurrency?
For Redis, executing APIs such as get, set, and eval are tasks one by one. These tasks will be executed by Redis threads. The tasks are either executed successfully or failed. This is Redis The command is atomic for reasons.
All APIs provided by Redis itself are atomic operations. Transactions in Redis actually ensure the atomicity of batch operations.
The above is the detailed content of What are the atomic operations of redis?. For more information, please follow other related articles on the PHP Chinese website!