当前位置:网站首页>Ensure database and cache consistency

Ensure database and cache consistency

2022-06-22 23:08:00 Bald Xiake

programme 1: Sync delete

The core processes :

Update the database data first

Then delete the cached data

The problem is :

1) Failed to delete cache. Dirty data exists

2) It is difficult to collapse all update database entries
Modify directly in the database , Cache does not change


programme 2: Delay double delete

The core processes :

Delete cached data

Update database data

Wait for a short time

Delete the cached data again

The problem is :

1) The delay time is difficult to confirm

Whether it's a delay of a second or a few seconds , It's actually hard to confirm , You can't delay for a few minutes , Because if you delay for a few minutes , Then there may be dirty data in these minutes , So it's hard to determine the time .

2) The consistency of data cannot be absolutely guaranteed


programme 3: Asynchronous monitoring binlog Delete + retry

The core processes :

Update the database

monitor binlog Delete cache

Cache deletion fails through MQ Try again and again , Until the deletion is successful
The overall flow chart is as follows :
 Insert picture description here
Refer to how to ensure the consistency of cache and database ( Super detailed case ) Database cache consistency solution

原网站

版权声明
本文为[Bald Xiake]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206222046400313.html