intermediateSystem Design — Caching Patterns & CQRS
A product page is loading slowly because the database query joins 5 tables. The data rarely changes. How do you implement caching?
Cache-Aside with write-through invalidation: 1) Build a ProductView DTO that contains all 5-table join result (denormalized). 2) Serialize to JSON and cache: redis.set('product:page:'+id, json, Duration.ofHours(6)). 3) On product update (any of the 5 tables): delete ALL related product page caches. 4) Cache warming: after update, proactively re-fetch and cache (write-through). 5) Cache stampede pr
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
A product page is loading slowly because the database query joins 5 tables. The data rarely changes. How do you implement caching?