datarekha
MLOps Medium Asked at AmazonAsked at MetaAsked at NetflixAsked at Stripe

What is the difference between a database and a cache, and how does cache-aside work?

The short answer

A database normally owns durable, authoritative records and transactional constraints. A cache keeps a temporary copy optimized for repeated low-latency reads. In cache-aside, the application checks the cache, reads the database on a miss, then populates the cache with a TTL; correctness still requires invalidation, stampede protection, and database fallback.

How to think about it

The database is normally the system of record: durable writes, transactions, constraints and recovery. A cache is a faster, potentially stale copy of data that can be reconstructed from the source of truth.

Cache-aside reads the cache first. On a miss, the application reads the database, returns the value and stores it in the cache with a TTL. Production design must address invalidation, hot-key stampedes, negative caching, cache failure and acceptable staleness.

Learn it properly System design boundaries

Keep practising

All MLOps questions

Explore further

Skip to content