Capping and Trimming Streams
Control stream memory growth by capping length with MAXLEN, trimming by ID with MINID, and using approximate trimming for performance.
Streams Grow Forever
Unless told otherwise, a Redis Stream keeps every entry you append. For high-throughput producers this means unbounded memory growth. Capping and trimming let you keep streams to a manageable size.
Capping at Add Time
The cleanest approach is to cap during XADD using MAXLEN. Redis evicts the oldest entries to keep the length at or below the limit.
XADD events MAXLEN 1000 * action login user 42All lessons in this course
- What are Redis Streams?
- Stream Data Structures & Commands
- Stream Message Persistence
- Capping and Trimming Streams