XDEL
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.
Return value
Section titled “Return value”| 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.
Examples
Section titled “Examples”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) 1127.0.0.1:6379> XLEN jobs(integer) 1Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.