Currently if you want to remove all messages which where delivered you need todo first a xinfo
to get all groups. Get from every group the last-delivered-id
and use the oldest one to do a xtrim on this stream. It would be great if there would be a buildin command doing this. I know about the maxlength on xadd but this would trims also not delivered messages.
Comment From: Seldaek
The required process is XINFO => XRANGE => XDEL on all message ids which are found. You can't even use XTRIM as the OP mentions.
I think ideally this might be a new flag on XTRIM, like XTRIM key MAXLEN [~] count [ACKED]
which if you pass it it would only trim acked messages. I am not sure how this would cope with a stream with multiple groups though. I assume messages would need to be acked by every group before being trimmed away?
Alternative idea might be to add the flag on XACK, like XACK key group ID [ID..] [DEL]
would delete the messages being acked after acking, but only if they have been acked by all groups.
Comment From: dcecile
XTRIM
feature request is at #5774
Comment From: sundb
Implemented by https://github.com/redis/redis/pull/14130