当前位置:网站首页>Steps to update data to database and cache
Steps to update data to database and cache
2022-08-05 13:58:00 【monkeySix】
Cache strategy: Cache aside
(1) Read request
The application first determines whether there is data in the cache. If the cache hits, it returns the data directly; if the cache does not hit, it queries the data from the database, writes it to the cache, and returns the data.
(2) Write request
Update the database first, then delete the data from the cache.
Question:
Why not just write back the data when writing the request?
In a concurrent scenario, data inconsistency may be found.For example, in the case of a write request, the database is updated first, and then the cache is updated. Request 1 first writes data 18 to the database, but the cache has not been updated. At this time, request 2 writes data 20 to the database, and the update cache data is 20. At this time, request 1 is updated again.Cache data, which will result in inconsistent data when the database data is 20 and the cached data is 18.
边栏推荐
猜你喜欢

LeetCode-772. Basic Calculator III

块分配器SLAB的内核实现

The power behind | Open up a new experience of intelligent teaching Huayun Data helps Tianchang Industrial School to build a new IT training room

C#员工考勤管理系统源码 考勤工资管理系统源码

图扑软件数字孪生油气管道站,搭建油气运输管控平台

Subnet Mask and Subnetting

响应式织梦模板花店鲜花类网站

【Endnote】插入文献时,自动弹出select matching reference

内存映射原理及mmap
![[vulhub]PostGresql远程代码执行漏洞复现(CVE-2018-1058)](/img/e5/76cbb7d0de3aa187e1f4b37582eee0.png)
[vulhub]PostGresql远程代码执行漏洞复现(CVE-2018-1058)
随机推荐
CF1714A 题解
[vulhub]PostGresql远程代码执行漏洞复现(CVE-2018-1058)
day7·拆包与装包
DSPE-PEG-Azide,DSPE-PEG-N3,磷脂-聚乙二醇-叠氮具有亲水和疏水性
一行简单的样式,让网页有「高级感」
day4·模块、包与矩阵列表变换
7.nodejs--egg框架简介、以及get、post请求
【CUDA学习笔记】什么是GPU计算
2022-08-04 Brighthouse: An Analytic DataWarehouse for Ad-hoc Queries
TVS和ESD的区别
leetcode 240. Search a 2D Matrix II 搜索二维矩阵 II(中等)
pandas连接oracle数据库并拉取表中数据到dataframe中、根据状态字段的变化情况筛选数据(shift滞后状态字段后作差、获取状态跳变的位置、最后跳变的位置为数据筛选的索引起点)
十分钟教会你如何使用VitePress搭建及部署个人博客站点
day10· __init__方法
C# employee attendance management system source code attendance salary management system source code
基于PCA模型的首个投资组合表现跟进(截止至2022.7.22)
Qt实现多国语言切换
day13·魔术方法__ call__与__del__
LeetCode高频题70. 爬楼梯,青蛙跳台阶,暴力递归的尝试,改记忆化搜索和动态规划代码
PySpark的存储不同格式文件