Skip to content
Commitwise
Menu

Cache-aside

Also called: Lazy loading

A caching pattern where the app checks the cache first, loads from the database on a miss and stores the result, and deletes the cached copy when data changes.

Definition

Also called lazy loading. Reads try the cache, fall back to the database, and fill the cache with a TTL. Writes update the database and delete the key, so the next read loads fresh data. The TTL bounds how long data can be stale if an invalidation is missed. It's the most common caching strategy because a cache failure only makes reads slower.

In practice

product(id) reads product:id from Redis; on a miss it queries PostgreSQL and stores the result for 10 minutes.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.