Home  >  Article  >  Database  >  What are the atomic operations of redis?

What are the atomic operations of redis?

anonymity
anonymityOriginal
2019-06-05 13:56:417371browse

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.

What are the atomic operations of redis?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn