A Persistent Log
A Redis stream is an append only log of entries. Each entry has an auto generated ID based on time plus a sequence number, and a set of field value pairs. Unlike pub sub, entries are stored, so consumers can read history and catch up after downtime.
- XADD appends an entry and returns its ID.
- XRANGE reads a range of entries.
- XREAD reads new entries, optionally blocking for arrivals.
Consumer Groups
The power of streams is the consumer group. Multiple workers join a group and Redis hands each entry to exactly one member, spreading load.
- XREADGROUP delivers entries to a consumer.
- XACK marks an entry processed.
- The pending entries list tracks delivered but unacknowledged entries, so a crashed worker leaves a record others can claim with XCLAIM.
Trimming
Because streams persist, they grow. XADD with MAXLEN or periodic XTRIM caps length so memory stays bounded, keeping only recent entries.
Streams give you durability, ordering, at least once delivery, and the ability to replay, making them Redis answer to message queues and event sourcing for many workloads.
Key idea
Redis streams are a persistent append only log where consumer groups deliver each entry to one worker with acknowledgment and replay, unlike fire and forget pub sub.