当前位置:网站首页>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
边栏推荐
- 企业微信免登录跳转自建应用
- 一些靶场的学习记录:sqli-labs、upload-labs、XSS
- Expression related to month, year and day in SVG
- 《内网安全攻防:渗透测试实战指南》读书笔记(四):权限提升分析及防御
- Unity获取真实地理地图应用Terrain笔记
- FUEL: Fast UAV Exploration using Incremental Frontier Structure and Hierarchical Planning
- About unity to obtain links related to the transformation of real geographic maps into 3D
- 读取修改resource文件夹下的json文件
- IT高薪者所具备的人格魅力
- Gets the maximum getmaxpoint in the list of all points
猜你喜欢

C # control the camera, rotate and drag the observation script (similar to scenes observation mode)

Plane definition - plane equation

内网渗透系列:内网隧道之dns2tcp

Chapter IV intangible assets

ABAP ALV显示金额与导出金额不一致

Dropping Pixels for Adversarial Robustness

VBA appelle SAP RFC pour réaliser la lecture et l'écriture des données

Protobuf 使用

Shapley Explanation Networks

Teach-Repeat-Replan: A Complete and Robust System for Aggressive Flight in Complex Environments
随机推荐
Online Safe Trajectory Generation For Quadrotors Using Fast Marching Method and Bernstein Basis Poly
05 use of array
Internal network security attack and defense: a practical guide to penetration testing (5): analysis and defense of horizontal movement in the domain
三分钟教你用Houdini流体>>解算粒子流体水滴
《内网安全攻防:渗透测试实战指南》读书笔记(八):权限维持分析及防御
Apache Hudi 如何加速传统的批处理模式?
CTF-MISC学习之从开始到放弃
C # control the camera, rotate and drag the observation script (similar to scenes observation mode)
Electronic builder package error: proxyconnect TCP: Dial TCP: 0: connectex
About unity to obtain links related to the transformation of real geographic maps into 3D
A series of articles, a summary of common vulnerabilities of Web penetration (continuously updated)
About USB flash drive data prompt raw, need to format, data recovery notes
Intranet security attack and defense: a practical guide to penetration testing (6): domain controller security
Idea shortcut
VBA调用SAP RFC实现数据读取&写入
Chapter V investment real estate
内网渗透系列:内网隧道之pingtunnel
TimelineWindow
SAP Query增强开发介绍
【Unity VFX】VFX特效入门笔记-火花制作