Usage
Parameters
The key of the stream.
The entry ID. Can be:
"*"- Fully automatic ID generation (recommended)"<ms>-<seq>"- Explicit ID (e.g.,"1526919030474-55")"<ms>-*"- Auto-generate sequence number for the given millisecond timestamp (Redis 8+)
The field-value pairs to store in the stream entry. Values are automatically serialized to strings.
Optional configuration:
Response
The ID of the added entry (e.g.,
"1526919030474-0").Returns null if nomkStream: true and the stream doesn’t exist.Examples
Add entry with automatic ID
Add multiple entries
Store complex data
Use explicit ID
Trim stream by maximum length
Trim stream by minimum ID
Don’t create stream if it doesn’t exist
Limit trimming operations
Stream IDs Explained
Format
Stream IDs have the format:<milliseconds>-<sequence>
milliseconds- Unix timestamp in millisecondssequence- Sequence number for entries added in the same millisecond
1678901234567-0
- Timestamp: 1678901234567 (March 15, 2023)
- Sequence: 0 (first entry in that millisecond)
Automatic Generation
Using"*" automatically generates an ID:
ID Ordering
IDs must always increase:Important Notes
Trimming Performance
- Use
comparison: "~"(approximate) for better performance - Exact trimming (
"=") may block for large deletions - Set
limitto prevent long blocking operations