XACKDEL

Syntax
XACKDEL key group [KEEPREF | DELREF | ACKED] IDS numids id [id ...]
Available since:
Redis Open Source 8.2.0
Time complexity:
O(1) for each entry ID processed.
ACL categories:
@write, @stream, @fast,

Acknowledges and conditionally deletes one or multiple entries (messages) for a stream consumer group at the specified key.

XACKDEL combines the functionality of XACK and XDEL in Redis Streams. It acknowledges the specified entry IDs in the given consumer group and simultaneously attempts to delete the corresponding entries from the stream.

Required arguments

key

The name of the stream key.

group

The name of the consumer group.

IDS numids id [id ...]

The IDS block specifying which entries to acknowledge and delete:

  • numids: The number of IDs that follow
  • id [id ...]: One or more stream entry IDs to acknowledge and delete

Optional arguments

KEEPREF | DELREF | ACKED

Specifies how to handle consumer group references when acknowledging and deleting entries. Available since Redis 8.2. If no option is specified, KEEPREF is used by default:

  • KEEPREF (default): Acknowledges the entries in the specified consumer group and deletes the entries from the stream, but preserves existing references to these entries in all consumer groups' PEL (Pending Entries List).
  • DELREF: Acknowledges the entries in the specified consumer group, deletes the entries from the stream, and also removes all references to these entries from all consumer groups' pending entry lists, effectively cleaning up all traces of the entries. If an entry ID is not in the stream, but there are dangling references, XACKDEL with DELREF would still remove all those references.
  • ACKED: Acknowledges the entries in the specified consumer group and only deletes entries that were read and acknowledged by all consumer groups.

This command is particularly useful when you want to both acknowledge entry processing and clean up the stream in a single atomic operation, providing fine-grained control over how entry references are handled.

Note:
When using multiple consumer groups, users are encouraged to use XACKDEL with the ACKED option instead of XACK and XDEL, simplifying the application logic.

Examples

XADD mystream * field1 value1 XADD mystream * field2 value2 XGROUP CREATE mystream mygroup 0 XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream > XPENDING mystream mygroup XACKDEL mystream mygroup KEEPREF IDS 2 1526919030474-55 1526919030474-56 XPENDING mystream mygroup XRANGE mystream - +

Return information

One of the following:

  • Array reply: -1 for each requested ID when the given key does not exist.
  • Array reply: For each ID:
    • Integer reply: 1 if the entry was acknowledged and deleted from the stream.
    • Integer reply: -1 if no such ID exists in the provided stream key.
    • Integer reply: 2 if the entry was acknowledged but not deleted, as there are still dangling references (ACKED option).
RATE THIS PAGE
Back to top ↑