当前位置:网站首页>Redis事务实现乐观锁原理
Redis事务实现乐观锁原理
2022-04-23 06:30:00 【梦江河梦】
事务实现
1)multi命令前通过watch命令监听key;
2)执行multi命令;
3)命令列表;
4)exec命令提交事务/discard命令回滚;
watch的实现原理
1)redis维护着一个全局的watch_keys,也是一个<key,value>结构,key是key+“&&”+连接id,代表是那个客户端连接要监听这个key,value是key的版本号,每次修改这个key,版本号会递增。
2)当执行exec命令的时候,会执行事务队列里的每一条命令,执行写命令的时候,会检查当前key是否存在于watch_keys里,如果存在,会检查两个的版本号是否相等,相等则执行这条写命令,不相等则不返回任何信息,然后删除watch_keys里对应的key;
版权声明
本文为[梦江河梦]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_42002747/article/details/124328344
边栏推荐
- Nodejs (I) event driven programming
- SAP自建表log功能开启
- 攻防世界MISC刷题1-50
- 内网渗透系列:内网隧道之icmp_tran
- When using flash, the code ends automatically without an error, the connection cannot be maintained, and the URL cannot be accessed.
- Houdini流体>>粒子流体导出到unity笔记
- Dropping Pixels for Adversarial Robustness
- Plane definition - plane equation
- A programmer who works four hours a day
- 随笔(不定时更新)
猜你喜欢
第四章 无形资产
Understanding the Role of Individual Units in a Deep Neural Networks(了解各个卷积核在神经网络中的作用)
使用flask时代码无报错自动结束,无法保持连接,访问不了url。
The projection vector of a vector to a plane
Internal network security attack and defense: a practical guide to penetration testing (5): analysis and defense of horizontal movement in the domain
MySQL8. 0 installation / uninstallation tutorial [window10 version]
When using flash, the code ends automatically without an error, the connection cannot be maintained, and the URL cannot be accessed.
Chapter V investment real estate
Houdini地形与流体解算(模拟泥石流)
【Unity VFX】VFX特效入门笔记-火花制作
随机推荐
Zhuang understand's TA notes (VI) < fakeenvreflect & rust, rust effect >
MySQL8. 0 installation / uninstallation tutorial [window10 version]
BUUCTF MISC刷题
内网渗透系列:内网隧道之icmptunnel(jamesbarlow师傅的)
Teach-Repeat-Replan: A Complete and Robust System for Aggressive Flight in Complex Environments
SAP Query增强开发介绍
Protobuf 使用
Using lambda expression to solve the problem of C file name sorting (whether it is 100 or 11)
《内网安全攻防:渗透测试实战指南》读书笔记(六):域控制器安全
FUEL: Fast UAV Exploration using Incremental Frontier Structure and Hierarchical Planning
Gets the maximum getmaxpoint in the list of all points
Houdini terrain and fluid solution (simulated debris flow)
TA notes of Zhuang understand (zero) < bedding and learning methods >
Nodejs (four) character reading
爬虫学习笔记,学习爬虫,看本篇就够了
内网渗透系列:内网隧道之icmp_tran
Reading notes
C smoothprogressbar custom progress bar control
庄懂的TA笔记(零)<铺垫与学习方法>
CTF攻防世界刷题51-