advanced

Cache-aside

Let the application read-through on miss and write the cache after database reads, accepting miss and stampede handling work.

Cache-aside lets the application manage cache population: on read miss, load from database, then set cache; on write, update database then delete or update cache. It is flexible and works with any cache store but requires careful miss and stampede handling.

Writers must invalidate or update cache to avoid long inconsistency windows. Read replicas plus cache-aside need clarity on which source populates cache after writes.

On interviews: walk through read miss and write update sequences, explain stampede risk on hot keys, and compare to write-through.

Common pitfalls: delete cache before DB commit causing extra misses; never invalidating on delete; populating cache from stale replica.

The trade-off is flexibility versus complexity—know when the simpler path is enough.

Checklist:

  • Define read miss load path.
  • Invalidate or update cache on every write.
  • Add stampede protection on hot keys.
  • Align cache source with consistency needs.