当前位置:网站首页>Consistency between database and cache data
Consistency between database and cache data
2022-06-21 06:50:00 【y_ bccl27】
For this cache and database data consistency problem , There is a classic solution , Namely Cache Aside Pattern.
Cache Aside Pattern The three solutions are as follows :
1. hit : The program first reads data from the cache , If hit , Then return directly
2. invalid : The program first reads data from the cache , If you don't hit , Read from the database , After success, put the data into the cache
3. to update : The program first updates the database , Delete the cache
Update involves the consistency between cache and database , There is 4 It's possible :
1. Update cache first , Update the database
If the cache update succeeds , And update the database . But when updating the database, the update failed , At this time, the database data will be rolled back , The cache also needs to be rolled back , Only manual programming can delete the cache , This is a troublesome thing , Therefore, this strategy is unreasonable in the sequence of execution .
2. Update the database first , Update the cache again
Threads A The updated database will key Set to 1, And then this time CPU Resources are B The thread grabbed ,B The thread updates the database and will key Set to 2 And put it in the cache key Also updated to 2, Then the thread B performed . next , Threads A Got this CPU resources , take key be equal to 1 Updated to cache , This is very likely to happen . Cache the latest data , Should be key be equal to 2, however
边栏推荐
猜你喜欢

0-1背包问题 (暴力递归 / 动态规划)

Issue 7: roll inside and lie flat. How do you choose

Recursively establish a chained binary tree, complete the traversal of the first, middle and last order and other functions (with source code)

五层参考模型各层总结

Modbus poll v9.9.2 build 1690 MODBUS test tool single file version
![[JS] intercepting string](/img/8c/3b0f638c30e3665907dcbb9336acd8.png)
[JS] intercepting string

Tweenmax irregular geometry background with animation JS effect

第4篇:从硬件/源码视角看JVM内存模型

156-Rust和Solana环境配置

GEO2R:对GEO数据库中的数据进行差异分析
随机推荐
Course design of simulated bank deposit and withdrawal management system in C language (pure C language version)
File类的构造方法和各种常用的方法
Construction methods of file class and various common methods
不给糖就捣蛋svg万圣节js特效
关于#mysql#的问题,如何解决?
GEO2R:对GEO数据库中的数据进行差异分析
Are you sure about this filter?
数据可视化实战:数据处理
第13期:Flink零基础学习路线
154 Solana distribution token
(各种规律数的编程练习)输出范围内的素数,一个整数的分解质因数,两个数的最大公约数和最小公倍数以及水仙花数和完数等等
[JDBC from starting to Real combat] JDBC Basic clearance tutoriel (Summary of the first part)
Pyg tutorial (6): customizing the messaging network
scikit-learn中的Scaler
使用cell ranger进行单细胞转录组定量分析
【GNN】GNN图神经网络工具箱的应用和matlab仿真
c技能树评测
【查询数据表中第三行数据】
Zongzi battle - guess who can win
出现ConcurrentModificationException这个异常报错,怎么处理?