Scaling · Intermediate · 12 min

Caching

Follow cache hits, misses and invalidation while keeping SQL authoritative.

STEP 1 / 13
Start with a busy database — isometric concept diagramThe database remains the source of truth. Components: 1. Readers. Representative clients, not a literal user count; 2. Application. Logical component or processing boundary; 3. SQL source of truth. Durable or explicitly scoped state. Connections: 1. Readers to Application: Start with a busy database; 2. Application to Readers: Reply: Application; 3. Application to SQL source of truth: Start with a busy database; 4. SQL source of truth to Application: Reply: SQL source of truth. Illustrations are conceptual, not deployed capacity or user counts.Readers → Application: Start with a busy database1Application → Readers: Reply: Application2Application → SQL source of truth: Start with a busy database3SQL source of truth → Application: Reply: SQL source of truth4Readers: representative traffic illustration; figure count is not a workload measurement.1ReadersRepresentative clients, not aliteral user countApplication: Logical component or processing boundary2ApplicationLogical component or processingboundarySQL source of truth: Durable or explicitly scoped state3SQL source of truthDurable or explicitly scoped state
1Readers2Application3SQL source of truth
  1. 1Readers → ApplicationRequestStart with a busy database
  2. 2Application → ReadersReplyReply: Application
  3. 3Application → SQL source of truthRequestStart with a busy database
  4. 4SQL source of truth → ApplicationReplyReply: SQL source of truth

Conceptual illustration · figures do not imply user counts, deployed capacity or replica counts.

3 components visible · Readers + Application + SQL source of truth highlighted

Orange: request / query · Blue: reply · Purple: event / control · Arrows show direction; speed is illustrative.

You’ll learn

  • Trace cache-aside with separate application calls.
  • Distinguish a cached copy from authoritative data.
  • Plan for invalidation races and cold-cache load.

PUT THE IDEA TO WORK

From learning to practice

RELATED PATTERNS

Cache-aside ↗

Further reading

Microsoft · Cache-aside ↗