在 DB 前面放一层 cache-aside(Redis/Memcached),使读取命中内存,给条目设置 TTL 并在写入时使其失效(invalidate),加入踩踏保护(stampede protection),使一个冷键无法对 DB 释放一场惊群(thundering herd),并把**热点键(hot keys)**分散到多个 replica 上,使一个热门键不会烧毁单个节点。
text
┌── hit ──▶ return value
request ──▶ cache│
└── miss ─▶ lock ─▶ DB read ─▶ set(TTL) ─▶ return
│
(only ONE miss populates; others wait)
DB writes ──▶ invalidate/update key
