当前位置:网站首页>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 .
边栏推荐
- OV7725 yuv 640*[email protected] 配置文件
- Cloud VR: the next step of virtual reality specialization
- "Deprecated gradle features were used in this build, making it incompatible with gradle 6.0" problem solving
- Mock服务moco系列(二)- Json格式、File文件、Header、Cookie、解决中文乱码
- Ch582 ble 5.0 uses Le coded broadcast and connection
- Mongodb cluster and sharding
- Landmark buildings around the world
- SLA 、SLO & SLI
- NPDP多少分通过?如何高分通过?
- 图的相关操作
猜你喜欢

Ch582 ble 5.0 uses Le coded broadcast and connection

精彩记录

Wu Enda's machine learning programming operation cannot be suspended pause problem solved

云流化和云桌面有什么关系

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

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

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

喜讯!瑞云科技被授予“海上扬帆”5G融合应用专委会成员单位

排序还需要了解的信息以及链表

Li Kai: the interesting and cutting-edge audio and video industry has always attracted me
随机推荐
imx6 RTL8189FTV移植
Hit the test site directly: summary of common agile knowledge points in PMP examination
Who is responsible for the problems of virtual idol endorsement products?
Cloud XR面临的问题以及Cloud XR主要应用场景
Mysql database common commands
Problems faced by cloud XR and main application scenarios of cloud XR
Notes on Flickr's dataset
Creation of unity Bezier curve
Ch582 ble 5.0 uses Le coded broadcast and connection
UnitTest框架应用
SLA 、SLO & SLI
Lwip之内存与包缓冲管理
Dating activity records
图的相关操作
实时云渲染有哪些优势
Idea 必备插件
Food safety | eight questions and eight answers take you to know crayfish again! This is the right way to eat!
Mock service Moco series (I) - introduction, first demo, get request, post request
SVN客户端(TortoiseSVN)安装及使用说明
Mock服务moco系列(一)- 简介、第一个Demo、Get请求、Post请求