缓存策略-五种
2020-09-24 本文已影响0人
7d972d5e05e8
参考文章:
缓存使用过程中的五种策略总结及优缺点组合分析
读策略
第一种:Cache-Aside

第二种:Read-Though Cache

写策略
第一种:Write-Through Cache

和Write-Back很相似,但是它会同时写入数据库。
优点:
1、读写数据一致性高,不会读取过期数据
缺点:
1、写数据路径变长,性能下降
第二种:Write-Around
这种策略下,数据直接写入数据库。应用程序可以失效缓存,也可以等待缓存TTL过期主动失效。
第三种:Write-Back

优点:
1、写到缓存即可返回,异步刷新数据到数据库,性能高。
2、读写一致性高,不会出现读到过期数据
缺点:
1、缓存宕机,数据丢失。不过缓存有持久化的话,影响较小