Learn

VISUAL GUIDE · SCALING & CACHING

Where a cache helps (and where it lies)

Step 4 of 9: A miss reads the store and fills the cache

STEP 4 / 9ORIGINAL SKETCH
GET /abc123get, set on missread alias302 LocationBrowserRedirect serviceAlias cacheTTL 60 sempty, then filledAlias storesource of truth
A browser asks a redirect service for a short link; the service checks a cache, falls back to the alias store on a miss, checks a disabled list, and a link owner or moderator can edit the store, purge the cache, or disable a link.

Where the time goesIllustrative · see assumptions

  • Cache read (miss)1 ms
  • Store read8 ms
  • Cache write1 ms

Total ≈ 10 ms

4 / 9
  1. No cache
  2. Add a cache
  3. Cache hit
  4. Cache miss
  5. Link changes
  6. Stale hit
  7. TTL bounds it
  8. Purge
  9. Deny-list

STEP 4 OF 9 · CACHE MISS

A miss reads the store and fills the cache

For a link nobody has opened in the last minute, the cache has nothing. The service reads the row from the store, writes it into the cache with a fresh TTL, and answers.

A miss is slightly slower than having no cache at all, because you paid for a cache lookup first. That is fine when most reads are hits. When a popular key expires or the cache restarts empty, many requests can miss together; letting only one request refill the key avoids that stampede.

Why it matters. Misses decide how much load reaches the store after a restart or an expiry. Plan for the cold cache, not only the warm one.