当前位置:网站首页>Redis cache update strategy actively
Redis cache update strategy actively
2022-08-09 09:58:00 【ruochen】
- Cache Aside Pattern: By the caller of the cache, the cache is updated at the same time as the database is updated
- Read/Write Through Pattern: The cache and the database are integrated into a service, and the service maintains the consistency.The caller calls the service without having to care about cache coherency
- Write Behind Caching Pattern: The caller only operates the cache, and other threads asynchronously persist the cached data to the database to ensure eventual consistency
- Comparatively speaking, the
Cache Aside Pattern
is more reliable - There are several issues to consider when manipulating caches and databases - delete cache or update cache?- Update the cache: Update the cache every time the database is updated, and there are many invalid writes - Delete the cache: Invalidate the cache when updating the database, and update the cache when querying (Better) - How to ensure the cache and databaseThe operation succeeds or fails at the same time?(Atomicity) - Monolithic system: transaction control - Distributed system: Using distributed transaction schemes such as TCC - Operation cache or database first?(Thread safety) - Delete the cache first, then operate the database - First operate the database, then delete the cache - Since redis is much faster than MySQL, solution 2 is preferred
insert image description here - The best solution for cache update strategy- Low consistency requirement: Use Redis's own memory elimination mechanism- High consistency requirement: Active update, and take timeout culling as the bottom line - Read operation: - Return directly if the cache hits- If the cache misses, query the database, write to the cache, and set the timeout period. - Write operation: - write to the database first, and then delete the cache - to ensure the atomicity of database and cache operations
边栏推荐
- LeetCode75:颜色分类-C语言一次遍历求解
- Command line query database
- What is the reason for the suspended animation of the migration tool in the GBase database?
- Multi-threaded cases - timer
- nacos从下载到安装集群的
- Tigase插件编写——注册用户批量查询
- Openwrt配置Aria2(Hg255d)
- Arrays.toString( )打印二维数组
- Firebase+Facebook 授权 web 登录提示域名验证或跳转错误
- 记录一次被入侵5900端口经历
猜你喜欢
随机推荐
Win系统 - 罗技 G604 鼠标蓝灯闪烁、失灵解决方案
MySQL全文索引
3. Coding method
Secretive present: in modern times
Tigase插件编写——注册用户批量查询
LPP code and its comments
五个不同事物隔离级别,七个事物传播行为
多线程案例——阻塞式队列
Tom Morgan | 人生二十一条法则
The GNU Privacy Guard
2021-04-26QGIS3.10加载天地图影像(地图瓦片)的一种方法
条件控制语句
快速解决MySQL插入中文数据时报错或乱码问题
6.Map interface and implementation class
MySQL约束关系,你必须要知道的知识点!
pycharm在创建py文件时如何自动注释
2.Collection interface
LeetCode148:排序链表 归并排序,思路清晰,C语言练习看过来!
4. Generics and Utilities
[Personal study summary] CRC verification principle and implementation