Caching and Sessions with Redis
About This Course
Add caching, session storage, rate limiting, and event fan-out to your SaaS backend using Redis a fast in-memory key-value store that sits beside your database and takes the hot read traffic off it. Learn the kv data model from first principles, then apply it to five real SaaS patterns: cache-aside for a slow endpoint, Redis-backed sessions so logins survive a server restart, per-IP and per-user rate limiting, and pub/sub for fire-and-forget events like "user signed up". Every lesson leans on Claude Code you describe what you want, Claude Code writes the code, and the left-hand helper walks you through what came back. By the end of this course you will understand when a SaaS app needs Redis, what each of the five patterns is for, and how to tell Claude Code to add them to your own API.</description><parameter name="shortDescription">Add caching, sessions, rate limiting, and event fan-out to your SaaS backend with Redis five hands-on labs where Claude Code writes the code and you learn when and why each Redis pattern is used.
Course Curriculum
5 Lessons
What Redis is and the kv data model - Lab Exercises
By the end of this lab you will know what a key-value store is, which Redis data types your SaaS app actually uses (strings, hashes, lists, sets), and how a Node app talks to Redis. You will drive Claude Code to add a /favorites/:userId endpoint that reads a per-user set from Redis, backed by data you seed with redis-cli.
Cache-aside pattern with Redis - Lab Exercises
By the end of this lab you will understand the cache-aside pattern (read-through cache with explicit writes on miss) and the TTL-based invalidation it depends on. You will direct Claude Code to add caching to Lumen Trail's slow /popular-routes endpoint so repeat callers get sub-millisecond responses while the first caller still pays the real cost, and you will see firsthand what happens when the cache goes cold.
Session storage with Redis - Lab Exercises
By the end of this lab you will know why in-memory sessions fall apart in production and how to move them to Redis so they survive server restarts and multiple server instances. You will direct Claude Code to migrate Lumen Trail's /login, /me, and /logout endpoints to use Redis-backed sessions with a 7-day TTL, and you will verify the fix by restarting the server mid-session.
Rate limiting with Redis - Lab Exercises
By the end of this lab you will know how to protect a SaaS API endpoint from abuse using Redis-backed counters. You will implement both the fixed-window and sliding-window patterns, understand the trade-off between them, and return proper 429 Too Many Requests responses with a Retry-After header on the Lumen Trail POST /routes endpoint.
Pub/sub for lightweight events with Redis - Lab Exercises
By the end of this lab you will know how to decouple slow follow-up work from your HTTP request path using Redis pub/sub. You will refactor Lumen Trail's POST /signup so it publishes a user-signed-up event and returns in under 20 ms, while a separate worker process subscribes to that channel and sends the welcome email and records the analytics asynchronously.