1.Redis vs. MySQL transaction
(1) The difference between rollback and discard: If 2 statements have been successfully executed, 3rd error rollback, the impact of the first 2 statements has disappeared discard the impact of the first 2 statements is still present (2) The following statement error in multi may have two scenarios: A. There is a problem with the grammar itself, in which case all statements will not execute B. The syntax itself is fine, but there is a problem with the applicable object, such as using the Zadd command to manipulate the lists object. After exec, execute the correct statement, skipping inappropriate statements (3) Thinking about buying tickets now there is only one ticket, and many people buy tickets, so it is necessary to pay attention to their own ticket when there is still more than tickets Redis affairs, the start is optimistic lock, only responsible for monitoring key has been changed set number 1/ /ticket quantity is 1 set Money 100//account balance is watch number money//In order to ensure the ticket and account balance is sufficient, here both monitor multi//Open transaction DECR number//votes minus one decyby money 55//account balance reduced EXEC//executive Affairs to test, you can open a terminal, modify the number and money before exec, observe the results of execution can be seen, any of the number and money change, the transaction will not be able to perform