Cache-Aside
also: lazy loading
The default caching pattern: check the cache, and on a miss load from the database and populate the cache yourself.
Cache-aside (lazy loading) is the most common caching pattern: the application checks the cache first; on a hit it returns the value, on a miss it reads the database, writes the result into the cache, and returns it. The cache sits beside the database, and the app manages it.
Worked example: a user-profile read checks Redis, misses, fetches from Postgres, stores it in Redis with a TTL, and returns — the next read for that user hits the cache. Gotcha: the classic bug is a stale write path — if you update the database but forget to invalidate or update the cache, readers see old data until the TTL expires; cache-aside must pair with an explicit invalidation strategy.