roadmaps / cache-aside-redis

9 steps · ~45 min · intermediate · free · ships with the app

Cache-aside with Redis

Nimbus Books survived launch day — now success is the problem: every page load hammers PostgreSQL with the same expensive catalog query. Feel a slow store on real containers, then fix it the way the industry does: a Redis cache-aside layer. Watch a 1500 ms page drop to a few milliseconds, kill your cache on purpose to prove the store survives it, and meet the one problem every cache carries: stale data.

before you start

The 9 steps and what each one checks

Every step ends with a validation pass that inspects your actual containers. The lines below are the exact observations it makes. The instructions, hints and commented walkthroughs live in the app.

  1. step 1 of 9

    Reopen the store

    • check: container "web" is running
  2. step 2 of 9

    The catalog

    • check: container "db" is running
    • check: table "books" exists in "db"
  3. step 3 of 9

    Least privilege, day one

    • check: web → db is reachable on :5432
  4. step 4 of 9

    The 1500-millisecond problem

    • check: GET :80/ on "web" contains "Nimbus Books"
    • check: GET :80/ on "web" contains "The Pragmatic Programmer"
  5. step 5 of 9

    Enter Redis

    • check: container "cache" is running
    • check: web → cache is reachable on :6379
    • check: cache → db is blocked on :5432
  6. step 6 of 9

    Cache-aside

    • check: GET :80/ on "web" contains "Nimbus Books"
    • check: key "cache:books" exists in "cache"
  7. step 7 of 9

    Prove the hit

    • check: key "stats:hits" exists in "cache"
    • check: GET :80/ on "web" contains "served from cache"
  8. step 8 of 9

    The cache goes dark

    • check: key "stats:drills" exists in "cache"
    • check: container "cache" is running
  9. step 9 of 9

    The stale catalog

    • check: GET :80/ on "web" contains "Phoenix"
    • check: GET :80/ on "web" contains "served from cache"

Play it on your machine

This roadmap ships free with the app. The only requirement is a running Docker daemon.

$ npx torollo start

MIT licensed · source on GitHub