• redis 事物和锁


    127.0.0.1:6379> set wang 100
    OK
    127.0.0.1:6379> set zhao 200
    OK
    127.0.0.1:6379> multi
    OK
    127.0.0.1:6379> decrby zhao 100
    QUEUED
    127.0.0.1:6379> incrby wang 100
    QUEUED
    127.0.0.1:6379> exec
    1) (integer) 100
    2) (integer) 200
    127.0.0.1:6379> get zhao
    "100"
    127.0.0.1:6379> get wang
    "200"
    127.0.0.1:6379> mget zhao wang
    1) "100"
    2) "200"
    127.0.0.1:6379> multi
    OK
    127.0.0.1:6379> decrby zhao 100
    QUEUED
    127.0.0.1:6379> incrby wang 100
    QUEUED
    127.0.0.1:6379> discard
    OK
    127.0.0.1:6379> mget zhao wang
    1) "100"
    2) "200"
    
    127.0.0.1:6379> set ticket 1
    OK
    127.0.0.1:6379> set lisi 300
    OK
    127.0.0.1:6379> set wang 300
    OK
    127.0.0.1:6379> multi
    OK
    127.0.0.1:6379> decr ticket
    QUEUED
    127.0.0.1:6379> decrby lisi 100
    QUEUED
    127.0.0.1:6379> exec
    1) (integer) -1
    2) (integer) 200
    
    127.0.0.1:6379> set ticket 1
    OK
    127.0.0.1:6379> watch ticket
    OK
    127.0.0.1:6379> multi
    OK
    127.0.0.1:6379> decr ticket
    QUEUED
    127.0.0.1:6379> decrby wang 100
    QUEUED
    127.0.0.1:6379> exec
    (nil)
    127.0.0.1:6379> get ticket
    "0"
    127.0.0.1:6379> watch tocket want lisi
    OK
    127.0.0.1:6379> unwatch
    OK
    
    
  • 相关阅读:
    python编码的那些事
    算法基础与排序
    排序算法之low B三人组
    Django之反向生成url
    ipython的用法详解
    python3的zip函数
    Django中url的生成过程详解
    Django的ORM实现数据库事务操作
    Django的admin.py注册流程
    Django跨域请求之JSONP和CORS
  • 原文地址:https://www.cnblogs.com/sha-ka/p/12779523.html
Copyright © 2020-2023  润新知