Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

XDEL

Last updated
XDEL key id [id ...]
Group
Stream
Complexity
O(1) per ID
Arity
-3 (at least 3 words, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

XDEL removes the entries with the given IDs from the stream at key and returns how many it removed. IDs that are not in the stream are ignored.

Deleting entries does not change the stream’s last generated ID, so new entries still need higher IDs. An entry that is pending in a consumer group stays in that group’s pending list: reading the consumer’s history with XREADGROUP returns its ID with a nil body, and XCLAIM and XAUTOCLAIM drop it.

All IDs are checked before anything is deleted, so one malformed ID fails the whole call.

Case RESP2 RESP3
Stream exists Integer: the number of entries deleted Integer
Key does not exist Integer 0 Integer 0

Error replies: ERR Invalid stream ID specified as stream command argument, and WRONGTYPE if the key holds another type.

127.0.0.1:6379> XADD jobs 1700000000000-0 task resize
"1700000000000-0"
127.0.0.1:6379> XADD jobs 1700000000001-0 task upload
"1700000000001-0"
127.0.0.1:6379> XDEL jobs 1700000000000-0 1699000000000-0
(integer) 1
127.0.0.1:6379> XLEN jobs
(integer) 1

Same as Redis 7 and Valkey 8.

XTRIM, XADD, XACK, XINFO STREAM