Cache Strategies 缓存策略

本文介绍了缓存策略的四种常见类型:Cache Aside、Read Through、Write Through和Write Around。Cache Aside适用于读取密集型工作负载,当数据不在缓存中时,应用会从数据库查询并存储到缓存中。Read Through则在首次读取数据时自动填充缓存,但数据模型需与数据库一致。Write Through策略在写入时同步更新数据库和缓存。Write Around策略提高写性能,适合写密集型工作负载,但存在数据丢失风险。每种策略都有其适用场景和优缺点。
摘要由CSDN通过智能技术生成

Cache Aside

Cache-aside caches are usually general purpose and work best for read-heavy workloads. Memcached and Redis are widely used.
在这里插入图片描述
在这里插入图片描述

Read Process

在这里插入图片描述

  1. The application first checks the cache.
  2. If the data is found in cache, we’ve cache hit. The data is read and returned to the client.
  3. If the data is not found in cache, we’ve cache miss. The application has to do some extra work. It queries the database to read the data, returns it to the client and stores the data in cache so the subsequent reads for the same data results in a cache hit.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值