Cache-aside
Definition
Cache-aside is a caching strategy in which application code owns the cache: it reads from the cache, falls back to the data store on a miss, writes the loaded value into the cache, and deletes or updates cache entries after writes.
In practice
It is the most common way to add Redis or Memcached in front of a database because it needs no special cache features and only caches data that is actually requested. If the cache goes down, the application can still read the database, provided the database can take the extra load.
Every miss costs a cache round trip plus a database query, and a popular key that expires can trigger a stampede. Writes must invalidate the cache, and a slow reader can put a stale value back after the invalidation, so keep a TTL as a safety net. Loading logic is repeated in every service that reads the data.
Example
A GET /products/42 handler calls GET product:42 in Redis; on a miss it runs SELECT * FROM products WHERE id = 42 and stores the row with SET product:42 ... EX 600.