# Cache patterns — one-pager

BayLearn · System Design Interview Sprint

**Today’s idea:** A cache is a quick saved lookup, not the official record. Name hit %, miss QPS, TTL, and the stampede. Do not cache money, seats, or medical files.

| Word | Plain meaning |
|------|----------------|
| Quick saved lookup | Cache — fast, maybe stale |
| Official record | Database. Misses land here |
| Miss QPS | Peak × (1 − hit). Linkly 40k × 8% = **3,200/s** |
| Cache-aside | Ask lookup → miss → record → fill → return |
| Write-through | Write lookup and record together |
| Write-behind | Write lookup, record later — **not for money** |
| TTL + jitter | How long the saved copy may live; do not expire as a herd |
| Stampede | Whole class refreshes grades at once; lock or serve stale 2s |
| Invalidate | Delete the saved lookup on write |
| Hot set | Small slice that moves hit %. LRU the rest |

**What to say:** I picked this because of this number (or this rule). What I give up is this.

## Six rows

| Product | What | Hit / miss | TTL | Don’t do this |
|---------|------|------------|-----|----------------|
| Linkly | Redirect map | 92% → 3,200 miss/s | 60s + delete key | 301; cache as the map |
| PulseFeed | Built Home (`userId`) | Reads from copy | 10–30s | Likes as a ledger; photos in Redis |
| RideHail | Ping store already 30s | Skip second lookup | Overwrite is the clock | 1.3 TB/day in Redis |
| PayRail | Profile / token only | Capture: no cache | Short on profile | Write-behind $49 |
| ClinicDocs | Status only | Tiny | Few seconds | PHI / PDF in Redis |
| TicketDrop | Poll “wait” maybe | Seats: no cache | Very short if at all | Stale “12 left” |

CDN was a saved copy nearby. This lesson is the app’s quick saved lookup. If the cache dies, fall through and watch official-record QPS.

Use this as a pocket card while you practice out loud.
