Caches and copies
Treat every cache, replica and search index as a copy that can be stale or lost. Say how fresh it must be, and keep the source of truth in one place.
- Required 2
- Recommended 2
Required
Name the source of truth
RequiredFor every piece of data, one store is the source of truth. Caches, search indexes and replicas are copies that can be rebuilt from it.
Decide how stale a cache may be
RequiredGive every cached value an expiry or an invalidation rule, chosen for how stale it may safely be.
Recommended
Read from replicas only what may lag
RecommendedSend reads to a replica only when a few seconds of delay is acceptable. Read your own writes from the primary.
Keep search indexes in step
RecommendedUpdate the search index from the source of truth through a reliable queue, and rebuild it fully on a schedule.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/caches-and-copies.