Concept Flow - XTRIM for stream capping
Start with Redis Stream
Add new entries to stream
Check stream length
Is length > max length?
No→Continue adding entries
Yes
Trim stream to max length
Stream capped at max length
Wait for next entry to add
XADD adds new entries to a Redis stream and XTRIM trims it to keep the stream length within a maximum limit.