redis transaction processing

multi opens the transaction, exec executes the transaction

example:

set age 10

multi

set age 20

set age 30

exec

get age

final age=30

 

cancel transaction discard

 

Empty the command queue of the transaction and exit the transaction context, that is, the transaction is rolled back

set age 10

multi

set age 20

set age 30

discard

get age

 

final age=10

 

optimistic locking transaction processing watch

 

watch age, if other sessions modify the age after monitoring the age, it will not be able to commit when the transaction is committed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326525005&siteId=291194637