What are Redis Streams?
Answer
Redis Streams (introduced in Redis 5.0) is a persistent, append-only log data structure similar to Apache Kafka, but built into Redis. Each entry has an auto-generated ID (timestamp-sequence, e.g., 1700000000000-0) and contains field-value pairs. XADD stream * field value appends an entry. XREAD COUNT 10 STREAMS stream 0 reads entries. Key features: Consumer Groups (XGROUP) allow multiple consumers to process different entries from the same stream in parallel, with acknowledgement (XACK) to track processed entries — similar to Kafka consumer groups. This enables reliable, at-least-once processing of events, overcoming the fire-and-forget limitation of Pub/Sub. Use Streams for event sourcing, activity feeds, and durable inter-service messaging within a Redis environment.
More Redis Questions
View all →- Intermediate What is Redis Cluster and how does it shard data?
- Intermediate What is the difference between Redis Sentinel and Redis Cluster?
- Intermediate How do MULTI and EXEC work in Redis transactions?
- Intermediate What is WATCH and optimistic locking in Redis?
- Intermediate What is Lua scripting in Redis and when should you use it?