Before learning Redis, I still think I must tell you. It is also a sentence that I said a lot in my article. I think it will also apply to learning Redis, that is, when you contact the Reids command in the article, you don’t have to try Remember these commands , just read the API help documentation when you use them; it won’t be too late to understand them after you know how to use them or practice them .
Get started with Redis series
Get started with Redis series (1): Detailed explanation of ultra-full String string type
Get started with Redis series (2): Detailed explanation of ultra-full List list type (code graphic example)
Get started with Redis series (3): Detailed description of ultra-full set Set type (code graphic and text Example)
Getting started with Redis series (4): Detailed explanation of ultra-full hash Hash type (code graphic example)
Getting started with Redis series (5): Detailed explanation of ultra-all ordered collection Zset type Getting
started with Redis series (6): Detailed explanation of ultra-full Geospatial special type (Geographical location)
Get started with Redis series (7): Ultra-full HyperLogLog special types
get started with Redis series (8): Bitmaps special types
get started with Redis series (9): Transaction operations
1. Redis transaction
Speaking of redis transactions, it is necessary to understand the transaction itself.
(If you still have a small partner who understands the affairs, you can understand first)
But unlike transactions, there are only partial transactions in redis.
Because redis does not guarantee atomicity and does not have the concept of isolation, what does redis have?
- One time
- Sequentiality
- Exclusivity
Redis transactions can execute multiple commands at once, and there are three important guarantees:
2. Hand knock Redis transaction command:
The flow of a transaction:
1. Open the transaction (muti) |
---|
2. Order to join the team (specific operations) |
3. Execution transaction (exec) |
MULTI starts a transaction, then enters the command into the queue to the transaction, and finally executes the EXEC command and executes the transaction.
Start a transaction
Format: MULT
Execute all transaction block commands
Format: EXEC
Cancel transaction
Format: DISCARD
It can be seen that once the transaction is cancelled, the operations in the transaction are also cancelled.
At last
At the end, for a better reading experience, I put everything I want to say below, hehe.
I am a seed of decisions based on my will, serious share what I wrote blog has been the same creed.
If you can read this blog post, it means that we are still very destined; I hope it can bring you some help, the creation is not easy, take away the knowledge of my article, your three consecutive leave, like, comment, follow , Is my biggest motivation.