当前位置:网站首页>Redis implements optimistic lock
Redis implements optimistic lock
2022-04-22 00:53:00 【RB_ VER】
Pessimistic locking : I think it's going to go wrong all the time , Lock whatever you do , Affect performance .
Optimism lock : I don't think anything will go wrong at any time , So don't lock it , When updating, judge whether the data has been modified .
redis Realization :
Access thread 1
# 0 moment
set in 100
# 1 moment
set out 0
# 2 moment
watch in
# 3 moment
multi
# 4 moment
decrby in 20
# 5 moment
incrby out 20
# 6 moment
exec
....
# 10 moment
set in 1000
Access thread 2:
# moment 7
watch in
# moment 8
decrby in 10
# moment 9
incrby out 10
....
# moment 11
exec
# At this time, the transaction execution fails
have access to watch Achieve optimistic lock , Before updating the value , Will get and compare this value , Be similar to version Field .
If you fail , Then you can execute unwatch, And use... Again watch To monitor .
版权声明
本文为[RB_ VER]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211712126773.html
边栏推荐
- LeetCode_ 62 different paths
- Application of intelligent traversal test in regression test and robustness test
- 云原生爱好者周刊:寻找 Netlify 开源替代品
- 解决 idea web项目没有小蓝点的问题
- 实现Nest中参数的联合类型校验
- 解决Svelte项目使用pnpm后Prettier无效问题
- ApacheCon Asia 2022 演讲征集开始了!
- Serialization and transient keywords
- kubernetes集群之Pod说能不能让我体面的消亡呀?
- logstash导入movielens测试数据
猜你喜欢

SEO keyword expansion - Automatic Keyword expansion software free download

DR/AP4029 outdoor IPQ-4019/4029 Outdoor directional-antennas

ES6 new syntax parsing

Distributed transactions and Seata

.NET 20周年学习挑战赛| .NET 移动应用

R - Dropout

R-Dropout

redis持久化

I've got an offer, and I need some knowledge for the interview

Linuix cat instruction
随机推荐
[langage C] opération de fichier d'analyse approfondie [niveau avancé examen spécial]
LeetCode_ 62 different paths
面试题8——捕获的雨水
Interview question 9 - captured rainwater II
Jmeter压测MQTT结果分析
R-Dropout
Fundamentals of digital electronic technology 3.3 CMOS gate circuit (Part 2)
Rasa对话机器人连载五 第122课:Rasa对话机器人Debugging项目实战之银行金融对话机器人全生命周期调试实战-(一)
自动化测试框架有哪些优势?
看看项目经理是如何把一个项目带崩的
R-Dropout
Flattening multilevel bidirectional linked list-c language
js原型,原型链,构造函数
Rasa对话机器人连载一 第121课:Rasa对话机器人Debugging项目实战之电商零售对话机器人运行流程调试全程演示-1
[Niuke] you must brush the top101-01 linked list for the interview
实现Nest中参数的联合类型校验
阿里云EMAS 3月产品动态
星环科技基础软件产品全面落地开花,为企业数字化转型带来“星”动能
Structure of actual combat training module III
Binary search method