Usage
Parameters
The key of the stream.
One or more entry IDs to delete. Can be a single ID string or an array of IDs.
Response
The number of entries actually deleted.IDs that don’t exist are ignored and don’t contribute to the count.
Examples
Delete a single entry
Delete multiple entries
Handle non-existent IDs
Delete all entries individually
Conditional deletion based on data
Delete old entries by time
Delete with verification
Batch delete with error handling
Clear stream completely
Important Notes
XDEL vs DEL
XDELremoves specific entries from a stream (stream still exists)DELremoves the entire stream key
Performance
- XDEL is O(1) for each ID to delete
- Deleting N entries is O(N)
- More efficient to delete multiple IDs in one call than multiple calls:
Memory Reclamation
Deleted entries are removed from memory, but:- The stream key itself still exists (even if empty)
- Use
DELto completely remove an empty stream - XDEL doesn’t automatically delete the stream when it becomes empty
Return Value
The return value is the number of entries actually deleted:Use Cases
- Data cleanup: Remove processed or expired entries
- Error handling: Delete invalid entries
- Privacy compliance: Remove user data on request
- Space management: Delete old entries to free memory
- Selective retention: Keep only relevant entries