XADD
Add a new entry to a stream. SyntaxThe stream key
Optional maximum number of entries to keep in the stream (trims oldest entries)
Entry ID in format
ms-seq (milliseconds-sequence), or * to auto-generateField name (one or more field-value pairs required)
Field value
The ID of the added entry
- Auto-generated IDs use current Unix timestamp in milliseconds with sequence number
- IDs must be monotonically increasing
- Supports MAXLEN for automatic stream trimming
- Stream is created automatically if it doesn’t exist
XLEN
Get the number of entries in a stream. SyntaxThe stream key
The number of entries in the stream, or 0 if the key does not exist
XRANGE
Query a range of stream entries by ID. SyntaxThe stream key
Minimum entry ID (use
- for the smallest ID in the stream)Maximum entry ID (use
+ for the largest ID in the stream)Maximum number of entries to return
Array of entries, each containing an ID and field-value pairs
- Returns entries in chronological order (oldest to newest)
-and+are special IDs representing stream bounds- Supports COUNT for limiting results
XREVRANGE
Query a range of stream entries in reverse order. SyntaxThe stream key
Maximum entry ID (use
+ for the largest ID in the stream)Minimum entry ID (use
- for the smallest ID in the stream)Maximum number of entries to return
Array of entries in reverse chronological order
XREAD
Read entries from one or more streams. SyntaxMaximum number of entries to return per stream
One or more stream keys
Start ID for each stream (use
$ for new entries only)Array of streams with their entries, or null if no new entries
- Number of keys must match number of IDs
$special ID means “only new entries added after this call”- Returns null when no new entries are available
XTRIM
Trim the stream to a maximum length. SyntaxThe stream key
Maximum number of entries to keep (oldest entries are removed)
The number of entries removed from the stream
XDEL
Delete entries from a stream by ID. SyntaxThe stream key
One or more entry IDs to delete
The number of entries actually deleted
- Non-existent IDs are ignored
- Returns count of successfully deleted entries
XGROUP CREATE
Create a consumer group for a stream. SyntaxThe stream key
Consumer group name
Starting ID (
0 for all entries, $ for new entries only)Create the stream if it doesn’t exist
OK if the group was created successfully
- Returns error if group already exists
$means start from the last ID in the stream0or0-0means start from the beginning- MKSTREAM creates the stream if it doesn’t exist
XGROUP DESTROY
Destroy a consumer group. SyntaxThe stream key
Consumer group name to destroy
1 if the group was destroyed, 0 if it did not exist
XGROUP DELCONSUMER
Delete a consumer from a consumer group. SyntaxThe stream key
Consumer group name
Consumer name to delete
The number of pending messages that the consumer had before deletion
XREADGROUP
Read entries from a stream as part of a consumer group. SyntaxKeyword indicating consumer group read
Consumer group name
Consumer name within the group
Maximum number of entries to return per stream
One or more stream keys
Start ID for each stream (use
> for new entries only, or a specific ID to read pending messages)Array of streams with their entries, or null if no entries available
>means fetch only new messages never delivered to any consumer- Specific ID returns pending messages for this consumer
- Messages are added to the Pending Entries List (PEL)
- Creates consumer automatically if it doesn’t exist
- Messages must be acknowledged with XACK
XACK
Acknowledge processed messages in a consumer group. SyntaxThe stream key
Consumer group name
One or more entry IDs to acknowledge
The number of messages successfully acknowledged
- Removes messages from the Pending Entries List (PEL)
- Non-existent IDs are ignored
- Returns count of successfully acknowledged messages
XPENDING
Inspect pending messages in a consumer group. SyntaxThe stream key
Consumer group name
Start ID for detailed pending list (use
- for smallest ID)End ID for detailed pending list (use
+ for largest ID)Maximum number of pending entries to return
Summary or detailed list of pending messages depending on arguments provided
- Without start/end/count: returns summary (total pending, min ID, max ID, consumers)
- With start/end/count: returns detailed list with ID, consumer, idle time, delivery count
XCLAIM
Claim pending messages from other consumers. SyntaxThe stream key
Consumer group name
Consumer claiming the messages
Minimum idle time in milliseconds (only claim messages idle longer than this)
One or more entry IDs to claim
Array of successfully claimed messages
- Only claims messages with idle time >= min-idle-time
- Increments delivery count
- Updates delivery time to current time
- Transfers ownership to the claiming consumer
XAUTOCLAIM
Automatically claim oldest pending messages. SyntaxThe stream key
Consumer group name
Consumer claiming the messages
Minimum idle time in milliseconds
Start scanning from this ID (use
0-0 to start from beginning)Maximum number of entries to claim (default: 100)
Array with three elements: next cursor ID, array of claimed messages, array of deleted IDs
- Scans pending list from start ID
- Claims messages idle >= min-idle-time
- Returns next cursor for subsequent calls
- Default count is 100 entries
XINFO STREAM
Get information about a stream. SyntaxThe stream key
Stream metadata including length, first entry, last entry, last generated ID, and group count
XINFO GROUPS
Get information about consumer groups for a stream. SyntaxThe stream key
Array of consumer groups with metadata including name, consumer count, pending count, and last delivered ID
- Returns empty array if no groups exist
- Each group shows: name, consumer count, pending message count, last delivered ID