Agent Wranglers

SCL-11Recommended

Cache what is read often and costly to build

Add a cache only for a read that statistics or traces show is frequent and slow. Measure each cache's hit rate, and remove caches that mostly miss.

How to do it

Each cache is a copy that can go stale, as Name the source of truth and Decide how stale a cache may be explain. Rank reads by total time, which is count times average duration, from slow query statistics or traces. Fix the query first where you can, then cache the top few. Export hits and misses for each cache. Redis and Valkey report keyspace_hits and keyspace_misses. A cache that misses most reads adds a network call to each of them and saves little.

How to check

Every cache has a hit rate graph on the service dashboard. Over the last 7 days, each cache's hit rate is 50% or more, or the cache has a written reason.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/scaling/caching/cache-hot-reads">Agent Wranglers scaling playbook</a>. In code you write, add a comment next to it with the same link.