redis-Transaction Transaction

Source: Internet
Author: User

The goal of Redis is to be concise and efficient, because the transaction itself is a complex thing, and all we can't do is complicate the transaction ...
  
 
  1. multi,exec
  2. 127.0.0.1:6379> multi
  3. OK
  4. 127.0.0.1:6379> lpush fruits orange
  5. QUEUED
  6. 127.0.0.1:6379> lpush fruits nut
  7. QUEUED
  8. 127.0.0.1:6379> lpush fruits apple
  9. QUEUED
  10. 127.0.0.1:6379> exec
  11. 1) (integer) 1
  12. 2) (integer) 2
  13. 3) (integer) 3

The transaction does not support rollback in order to make redis simple enough, so be careful when writing code
Use watch to protect variables that don't want to be multi changed
  
 
  1. 127.0.0.1:6379> watch msg
  2. OK
  3. 127.0.0.1:6379> multi
  4. OK
  5. 127.0.0.1:6379> set msg "2008 hello wolrd"
  6. QUEUED
  7. 127.0.0.1:6379> exec
  8. (nil)
  9. 127.0.0.1:6379> get msg
  10. "12345" // 没有被改变
  11. 127.0.0.1:6379>



From for notes (Wiz)

redis-Transaction Transaction

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.