Skip to main content

Arguments

key
str
required
The key to of the stream.
id
str | *
required
The stream entry ID. If * is passed, a new ID will be generated automatically.
data
Dict[str, Any]
required
Key-value data to be appended to the stream.
maxlen
int
The maximum number of entries to keep in the stream. Mutually exclusive with minid.
approximate_trim
bool
default:"True"
Use approximate trimming (more efficient). When True, Redis may keep slightly more entries than specified. Defaults to True.
nomkstream
bool
default:"False"
Prevent creating the stream if it does not exist. Defaults to False.
minid
str
The minimum ID to keep. Entries with IDs lower than this will be removed. Mutually exclusive with maxlen.
limit
int
Limit how many entries will be trimmed at most (only valid with approximate trimming).

Response

The ID of the newly added entry.
redis.xadd("mystream", "*", {"name": "John Doe", "age": 30})
I