当前位置:网站首页>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 Patternis 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
边栏推荐
猜你喜欢

EndNote使用指南

蓄电池建模、分析与优化(Matlab代码实现)

OSCS开源软件安全周报,一分钟了解本周开源软件安全大事

实用小技能:一键获取Harbor中镜像信息,快捷查询镜像

EndNote User Guide

条件和递归

动态内存管理

Cisco common basic configuration of common commands

A Practical Guide to Building OWL Ontologies using Protege4 and CO-ODE Tools - Version 1.3 (7.4 Annotation Properties - Annotation Properties)

mac 上安装Redis和配置
随机推荐
MySQL常用存储引擎,你不可错过的知识点!
Sweet alert
【八大排序②】选择排序(选择排序,堆排序)
goproxy.io 证书过期
【机器学习】数据科学基础——机器学习基础实践(二)
Quick sort eight sorts (3) 】 【 (dynamic figure deduction Hoare, digging holes, front and rear pointer method)
2.Collection interface
Celebrate ranked 18
markdown转ipynb--利用包notedown
6.Map接口与实现类
Arrays.toString( )打印二维数组
常用的一些制表符号
A little experience sharing about passing the CISSP exam at one time
3.练习Thread
8.Properties property collection
常用命令之思科常用基础配置
Dream Notes 0809
Cisco common basic configuration of common commands
7.Collections工具类
Go-控制语句那些事