当前位置:网站首页>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 .
边栏推荐
- Hit the test site directly: summary of common agile knowledge points in PMP examination
- BiSeNet v1
- itextpdf实现多PDF文件合并为一个PDF文档
- 简述冒泡排序与快速排序
- H5测试点(思维导图)
- 实时云渲染有哪些优势
- UFT (QTP) - summary points and automated test framework
- PageHelper can also be combined with lambda expressions to achieve concise paging encapsulation
- Auditing related notes
- 简述Synchronized以及锁升级
猜你喜欢

What is the relationship between cloud fluidization and cloud desktop

How to judge the performance of static code quality analysis tools? These five factors must be considered

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

越来越成熟的Rust,都应用了哪些场景呢?

Thesis reading_ Multi task learning_ MMoE

Problems faced by cloud XR and main application scenarios of cloud XR

Dating activity records

CVE-2022-33891 Apache spark shell 命令注入漏洞复现

SVN客户端(TortoiseSVN)安装及使用说明

Cloud VR: the next step of virtual reality specialization
随机推荐
How many points did NPDP pass? How to pass with high scores?
更新|3DCAT实时云渲染 v2.1.2版本全新发布
Briefly describe synchronized and lock upgrade
Highlights
Update 3dcat real time cloud rendering V2.1.2 release
大话DevOps监控,团队如何选择监控工具?
BL602 开发环境搭建
Auditing related notes
「行话」| 用DevOps高效交付游戏,是种什么体验?
简述Synchronized以及锁升级
SDLC software development life cycle and model
Go language context control function execution timeout return
Drawing PDF tables (I) drawing excel table styles in PDF and downloading them through iText (supporting Chinese fonts)
CVE-2022-33891 Apache spark shell 命令注入漏洞复现
关于云XR介绍,以及5G时代云化XR的发展机遇
Postman快速上手
STM8S003F3 uart的使用
mongodb 集群及分片
简述聚簇索引、二级索引、索引下推
专访即构科技李凯:音视频的有趣、行业前沿一直吸引着我