当前位置:网站首页>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
边栏推荐
- C problem of marking the position of polygons surrounded by multiple rectangles
- How does Apache Hudi accelerate traditional batch mode?
- SAP GUI安全性
- C reads the registry
- 使用flask时代码无报错自动结束,无法保持连接,访问不了url。
- 03use of scanner class (console input)
- Houdini > fluid, rigid body export, learning process notes
- Teach-Repeat-Replan: A Complete and Robust System for Aggressive Flight in Complex Environments
- TimelineWindow
- Solve the problem of deploying mysql8 in docker with correct password but unable to log in to MySQL
猜你喜欢
SAP GUI安全性
VBA calls SAP RFC to read & write data
第五章 投资性房地产
MySQL in window10 version does not work after setting remote access permission
linux下mysql数据库备份与恢复(全量+增量)
SQL sorts string numbers
Shapley Explanation Networks
SAP自建表log功能开启
How does Apache Hudi accelerate traditional batch mode?
STO With Billing 跨公司库存转储退货
随机推荐
《内网安全攻防:渗透测试实战指南》读书笔记(六):域控制器安全
One of event management
第五章 投资性房地产
一些关于网络安全的好教程或笔记的链接,记录一下
C problem of marking the position of polygons surrounded by multiple rectangles
Internal network security attack and defense: a practical guide to penetration testing (8): Authority maintenance analysis and defense
linux下mysql数据库备份与恢复(全量+增量)
一些靶场的学习记录:sqli-labs、upload-labs、XSS
爬虫学习笔记,学习爬虫,看本篇就够了
ES6 uses recursion to implement deep copy
关于unity获取真实地理地图转3D化的相关链接
Double sided shader
Chapter IV intangible assets
常用Markdown语法学习
VBA調用SAP RFC實現數據讀取&寫入
STO With Billing 跨公司库存转储退货
Houdini>建筑道路可变,学习过程笔记
Unity gets a resource that is referenced by those resources
Weblux file upload and download
About unity to obtain links related to the transformation of real geographic maps into 3D