redis transaction control

1. Description: Now suppose there is a session modification process to be performed several times, you can consider several operations into one transaction, this treatment can make these instruments operate together to execute or cancel together. Redis is not in control of affairs in the traditional SQL transaction control as intelligent, redis transaction is to control all the instructions that can be executed both were executed, the instruction can not be executed error.

2. Instruction:

• On matters: multi 

• commit the transaction: exec

• Cancel the current queue of all operations: discard

for example:

EG1: 
the SET Age 18 
Multi 
the SET Age 99 
GET Age At this time the results of 18, because the transaction opened, set age 99 did not submit. 
Exec 

EG2: 
the SET Age 10 
the SET info lee 
Multi 
incr Age 
incr info (info string can not perform the increment operator) 
Exec 
execution results: age will be executed, and incr being given info, which reflects not succeed together with failure

  

 

Guess you like

Origin www.cnblogs.com/wxl123/p/11110802.html