Stream
XREAD
Reads data from one or multiple streams, starting from the specified IDs.
Arguments
keybodystring | string[]required
The key(s) of the stream(s). Can be a single stream key or an array of stream keys.
idbodystring | string[]required
The stream entry ID(s) to start reading from. Must match the number of keys provided.
Use $ to read only new messages added after the command is issued.
optionsbody
Response
Array<[string, Array<[string, string[]]>]> | null
Returns an array where each element represents a stream and contains:
- The stream key
- An array of messages (ID and field-value pairs)
Returns null if no data is available.
Single stream
const result = await redis.xread("mystream", "0-0");Multiple streams
const result = await redis.xread( ["stream1", "stream2"], ["0-0", "0-0"]);With count limit
const result = await redis.xread("mystream", "0-0", { count: 2 });Only new messages
const result = await redis.xread("mystream", `$`);[ ["mystream", [ ["1638360173533-0", ["field1", "value1", "field2", "value2"]], ["1638360173533-1", ["field1", "value3", "field2", "value4"]] ]]]