← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 2313.e.5.f.10.b.3.e.1.a.1.b.1

旁路与读穿责任不同

理解等级:中级

旁路缓存由应用先查缓存、未命中再读数据库并回填;读穿缓存将加载真源的责任封装在缓存组件内。两者都要处理加载失败与并发回填,差别在谁执行加载,而不是谁天然更一致。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Distributed Caching · 查看原书依据

      In read-through caching, the cache acts as an intelligent intermediary between your application and the database. When the application requests data, it only needs to talk to the cache, as follows: # Without read-through caching def get_product(product_id): product = cache.get(product_id) if not product: product = database.get(product_id) cache.set(product_id, product) return product # With read-through caching def get_product(product_id): return cache_client.get(product_id) # Cache handles DB interaction if needed Write through caching Write-through cache is a caching strategy that simultaneously writes data to the cache and the main memory.

    参考来源

    - 位置:《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) - 结论依据:原文的机制或对比支持以下核心判断:旁路缓存由应用先查缓存、未命中再读数据库并回填;读穿缓存将加载真源的责任封装在缓存组件内。 本卡将相邻说明中的适用限制保留为解释。 - 原始内容:In read-through caching, the cache acts as an intelligent intermediary between your application and the database. When the application requests data, it only needs to talk to the cache, as follows: # Without read-through caching def get_product(product_id): product = cache.get(product_id) if not product: product = database.get(product_id) cache.set(product_id, product) return product # With read-through caching def get_product(product_id): return cache_client.get(product_id) # Cache handles DB interaction if needed Write through caching Write-through cache is a caching strategy that simultaneously writes data to the cache and the main memory.