当前位置:网站首页>保证数据库和缓存的一致性
保证数据库和缓存的一致性
2022-06-22 20:47:00 【秃头侠客】
方案1:同步删除
核心流程:
先更新数据库数据
然后删除缓存数据
存在的问题:
1)删除缓存失败存在脏数据
2)难以收拢所有更新数据库入口
直接在数据库中修改,缓存不会改变
方案2:延迟双删
核心流程:
删除缓存数据
更新数据库数据
等待一小段时间
再次删除缓存数据
存在的问题:
1)延迟时间难以确认
到底是延迟一秒或者是几秒,这个其实很难确认,你总不能延迟几分钟吧,因为你如果延迟几分钟,那这几分钟可能就存在脏数据了,所以这个时间很难确定。
2)无法绝对保障数据的一致性
方案3:异步监听binlog删除 + 重试
核心流程:
更新数据库
监听binlog删除缓存
缓存删除失败则通过MQ不断重试,直至删除成功
整体流程图如下:
参考如何保障缓存和数据库的一致性(超详细案例)数据库缓存一致性解决方案
边栏推荐
- 2020-12-20
- 一个spark app demo
- Talk about SQL profile again: can I fix the execution plan?
- 下一个排列[发挥主观能动性发现规律]
- General trend wisdom to create inclined model and cut monomer
- 2021-01-29
- Developing salary management system based on C language course paper + source code and executable EXE file
- 2021-05-02
- Mysql8 installation and environment configuration
- SQL performance optimization method for interval retrieval
猜你喜欢

Las point cloud create mesh

Summary of just meal with 900W increase in playback and acclaim from station B users

In a frame because it set 'X-FRAME-OPTIONS' to' deny '

Experiment 4 operation comparison between NoSQL and relational database

The relationship between derivative and differential of function

2021-05-02
![[ongoing update...] 2021 National Electronic Design Competition for college students (III) interpretation of the anonymous four axis space developer flight control system design](/img/5d/71c75a3622f7814f385d04b6148074.png)
[ongoing update...] 2021 National Electronic Design Competition for college students (III) interpretation of the anonymous four axis space developer flight control system design

General trend wisdom to create inclined model and cut monomer

2021-04-05

leetcode. 11 --- container with the most water
随机推荐
2021-04-14
Using the hbuilder x editor to install a solution for terminal window plug-ins that are not responding
In a frame because it set 'X-FRAME-OPTIONS' to' deny '
2020-12-20
c语言---17 函数简介
Why do you perform performance tests before the software goes online? How to find a software performance testing organization
The required reading for candidates | PMP the test on June 25 is approaching. What should we pay attention to?
Introduction and example application of PostgreSQL string separator function (regexp\u split\u to\u table)
Mysql database DQL exercise
Experiment 4 operation comparison between NoSQL and relational database
新捷途X70S上市8.79万起,空间安全越级,不愧是网红国民大7座SUV
Talk about SQL profile again: can I fix the execution plan?
2021-08-21
2021-05-02
Greedy interval problem (2)
2020-12-04
How to change the dial on the apple Watch
Help customers' digital transformation and build a new operation and maintenance system
2020-12-20
Reinforcement learning weekly (issue 50): saferl kit, gmi-drl, rp-sdrl & offline meta reinforcement learning