DB के सामने एक cache-aside layer (Redis/Memcached) रखें ताकि reads memory पर लगें, entries को एक TTL दें और write पर invalidate करें, stampede protection जोड़ें ताकि एक cold key DB पर एक thundering herd न छोड़े, और hot keys को replicas में फैलाएं ताकि एक popular key एक अकेले node को न पिघलाए।
┌── hit ──▶ return value
request ──▶ cache│
└── miss ─▶ lock ─▶ DB read ─▶ set(TTL) ─▶ return
│
(only ONE miss populates; others wait)
DB writes ──▶ invalidate/update key
