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”

MechanismDataLifetime
Postgres + QueryAggregatesDurable
Redis PUBLISH + SSEIndividual eventsFire-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

Lesson 2.6 check

1. Redis Pub/Sub messages without subscribers…