Stream

XREAD

Reads data from one or multiple streams, starting from the specified IDs.

Arguments

streamsbodyDict[str, str]required

A dictionary mapping stream keys to their starting IDs. Use $ to read only new messages added after the command is issued.

countbodyint

The maximum number of messages to return per stream.

Response

List[List[Any]]

Returns a list where each element represents a stream and contains:

  • The stream key
  • A list of messages (ID and field-value pairs)

Returns empty list if no data is available.

Single stream
result = redis.xread({"mystream": "0-0"})
Multiple streams
result = redis.xread({"stream1": "0-0", "stream2": "0-0"})
With count limit
result = redis.xread({"mystream": "0-0"}, count=1)
Only new messages
result = redis.xread({"mystream": `$`})
[  ["mystream", [    ["1638360173533-0", ["field1", "value1", "field2", "value2"]],    ["1638360173533-1", ["field1", "value3", "field2", "value4"]]  ]]]
Loading search…