Multi
Set Sniper 1
Set//Command syntax error
All commands within the EXEC//transaction are not executed
Multi
Set Sniper 1
Lpush Sniper 3 Run-time exception,
Set Sniper2 3
At the end of the exec transaction, the first and third rows of the command execute, and the second row fails
Step A, compare, window one:
Watch Sniper
Multi
Set Sniper 3
Step B, window two: Set Sniper 6
Step c, window one: Exec end transaction
Step d, window one or window two: Get Sniper, value is 6
Conclusion: When you watch a variable, if the variable is changed in the transaction but the transaction does not end, at this point the variable is changed in the other place outside the transaction, then the variable change within the transaction will not work.
Watch command
Function: monitoring one or more keys, when the monitored key value is modified to block after the execution of a transaction.
However, there is no guarantee that other clients will not modify this key value, so we need to re-execute the command in the transaction after the failure of the transaction execution.
Note: After executing the EXEC command for a transaction, watch cancels the monitoring of all key values
Unwatch: Canceling monitoring
Redis Summary 4