The use of transactions in Redis

Source: Internet
Author: User
Tags redis rollback ticket

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.