当前位置:网站首页>MySQL optimistic lock
MySQL optimistic lock
2022-07-25 18:02:00 【Leon_ Jinhai_ Sun】
Optimistic locking holds that concurrent operations on the same data will not always occur , It's a small probability event , You don't have to lock the data every time , But in the process of updating, we will judge whether other people have updated this data during this period , That is to say Do not use the locking mechanism of the database itself , But through Program to achieve . On procedure , We can use Version number mechanism perhaps CAS Mechanism Realization . Optimistic lock is suitable for multi read applications , This can improve throughput . stay Java in java.util.concurrent.atomic The atomic variable class under the package is an implementation method that uses optimistic locking :CAS Realized .
1. Optimistic lock version number mechanism : Design a... In the table Version field version , The first time I read it , Will get version Value of field . Then update or delete the data , Will execute UPDATE ... SET version=version+1 WHERE version=version . At this time, if a transaction has changed this data , The modification will not succeed .
2. The timestamp mechanism of optimistic lock : Timestamp is the same as the version number mechanism , It's also when the update is submitted , Compare the timestamp of the current data with that obtained before the update , If both are consistent, the update is successful , Otherwise it's a version conflict . As you can see, optimistic lock is the programmer's permission to control the concurrent operation of data , Basically by adding a stamp to the data row ( Version number or time stamp ), So as to prove whether the current data is up-to-date .
边栏推荐
- 越来越成熟的Rust,都应用了哪些场景呢?
- NPDP多少分通过?如何高分通过?
- Auditing相关注解
- Automated test Po design model
- PageHelper还能结合Lambda表达式实现简洁的分页封装
- 更新|3DCAT实时云渲染 v2.1.2版本全新发布
- 大话DevOps监控,团队如何选择监控工具?
- Wu Enda's machine learning programming operation cannot be suspended pause problem solved
- 实时云渲染有哪些优势
- TME2022校园招聘后台开发/运营开发/业务运维/应用开发笔试(I)编程题的一点自我分析
猜你喜欢

如何判断静态代码质量分析工具的性能?这五大因素必须考虑

Auditing related notes

Tme2022 campus recruitment background development / operation development / business operation and maintenance / application development written examination (I) a little self analysis of programming q

Landmark buildings around the world

ORB_SLAM3复现——上篇

SLA 、SLO & SLI

绘制pdf表格 (一) 通过itext实现在pdf中绘制excel表格样式并且实现下载(支持中文字体)

imx6 RTL8189FTV移植

Unity 贝塞尔曲线的创建

Oracle使用impdp导入报错:ORA-39001: 参数值无效 ORA-39000: 转储文件说明错误 ORA-39088: 文件名不能包含路径说明
随机推荐
Brief introduction to clustered index, secondary index, index push down
RedisTemplate解决高并发下秒杀系统库存超卖方案 — Redis事务+乐观锁机制
Food safety | eight questions and eight answers take you to know crayfish again! This is the right way to eat!
更新|3DCAT实时云渲染 v2.1.2版本全新发布
Polynomial addition
面试官:说说 log.Fatal 和 panic 的区别
I'm also drunk. Eureka delayed registration and this pit!
go语言context控制函数执行超时返回
srec_cat 常用参数的使用
ORB_SLAM3复现——上篇
Talking about Devops monitoring, how does the team choose monitoring tools?
How to choose digital twin visualization platform
Li Kai: the interesting and cutting-edge audio and video industry has always attracted me
云VR:虚拟现实专业化的下一步
简述聚簇索引、二级索引、索引下推
食品安全 | 八问八答带你重新认识小龙虾!这样吃才对!
STM8S003F3 内部flash调试
Automated test Po design model
Which real-time gold trading platform is reliable and safe?
Creation of unity Bezier curve