知识卡片
空值缓存防重复穿透
不存在的键每次都未命中并查询数据库,会产生缓存穿透。以短TTL缓存不存在结果可减少重复查询;数据新建后可能暂时被旧空值遮住,因此要限制期限或及时失效,并防大量随机键占满缓存。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Distributed Caching · 查看原书依据
The solution is to store negative results. Just as a store might put up a Not Available sign for frequently requested but unavailable items, we can cache null results with a shorter TTL.
参考来源
- 位置:《Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…》第11章《Distributed Caching》(来源项目book-sources;源文件:extracted/Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…/_epub-src/OPS/ch11.xhtml)
- 结论依据:原文的机制或对比支持以下核心判断:不存在的键每次都未命中并查询数据库,会产生缓存穿透。 本卡将相邻说明中的适用限制保留为解释。
- 原始内容:The solution is to store negative results. Just as a store might put up a Not Available sign for frequently requested but unavailable items, we can cache null results with a shorter TTL.