Book 2 · Lesson 2.6
Redis Pub/Sub
- Contrast Postgres persistence with Redis pub/sub
- Simulate live feed while page is open
- Relate to radar SSE endpoint
Prerequisites: 2.5
TanStack Query polls summary metrics every 5s. Redis Pub/Sub pushes ephemeral events while the manager keeps the tab open.
Two speeds of “live”
| Mechanism | Data | Lifetime |
|---|---|---|
| Postgres + Query | Aggregates | Durable |
| Redis PUBLISH + SSE | Individual events | Fire-and-forget |
RedisPubSubLive — subscribe, then publish from analyzer.
Terminal lab
redis-cli SUBSCRIBE team-radar:live
Run a webhook while subscribed — see messages (when stack is up).
Teach-back prompt
What happens to pub/sub messages if no subscriber is connected?
Subscribe in terminal
Lab complete — nice work.