- Usage:
-
XACKDEL key group [ KEEPREF | DELREF | ACKED ] IDS numids id [ id ... ]
- Complexity:
- O(1) for each single item to delete in the stream, regardless of the stream size
- Since:
- 9.2.0
- ACL Categories:
- @fast, @write, @stream
KEEPREF(default, implicit): acknowledges and deletes messages immediately, leaving PEL references in other groups,DELREF: acknowledges, deletes, and forcibly removes PEL references from all other groups,ACKED: deletes a message only once no consumer group still needs it, meaning none has it pending (each has either acknowledged it or never picked it up), and no group can still deliver it later.-
-1: The key doesn't exist, the group doesn't exist, or the ID isn't in the group's PEL.
-
1: The entry was acknowledged and deleted, or a dangling PEL entry (whose stream entry was already deleted) was acknowledged.
-
2: The entry was acknowledged but not deleted because another consumer group still needs it (
ACKEDmode only).
The XACKDEL command is an extension of the XACK stream command that acknowledges the specified message IDs in group's pending entries list (PEL) and, depending on mode, deletes the underlying stream messages.
This is particularly useful when multiple consumer groups independently process the same stream and you need to reclaim space without deleting messages that another group still needs.
The command supports three deletion modes:
Examples
127.0.0.1:6899> XADD s5 * a 1
"1788350000000-0"
127.0.0.1:6899> XGROUP CREATE s5 g1 0
OK
127.0.0.1:6899> XGROUP CREATE s5 g2 0
OK
127.0.0.1:6899> XREADGROUP GROUP g1 cons1 COUNT 10 STREAMS s5 >
1) 1) "s5"
2) 1) 1) "1788350000000-0"
2) 1) "a"
2) "1"
127.0.0.1:6899> XACKDEL s5 g1 ACKED IDS 1 1788350000000-0
1) (integer) 2
127.0.0.1:6899> XLEN s5
(integer) 1
127.0.0.1:6899> XREADGROUP GROUP g2 cons1 COUNT 10 STREAMS s5 >
1) 1) "s5"
2) 1) 1) "1788350000000-0"
2) 1) "a"
2) "1"
127.0.0.1:6899> XACKDEL s5 g2 ACKED IDS 1 1788350000000-0
1) (integer) 1
127.0.0.1:6899> XLEN s5
(integer) 0
RESP2/RESP3 Reply
Array reply: a list of integer codes, one per requested ID, in the same order as the IDs are given.