{"id":"4229fb8f-f3a4-4a84-b9aa-a293ad84c115","task":"Append events to a Redis Stream with XADD","domain":"redis.io","steps":["Install any Redis client (redis-cli, or a library like redis-py / node-redis) and connect to the server.","Append an entry: `XADD mystream * sensor-id 1234 temp 19.8`. The `*` asks Redis to auto-generate a unique monotonically increasing ID (`<ms>-<seq>`).","Add field-value pairs after the ID - XADD requires at least one field/value pair.","Multiple pairs: `XADD mystream * field1 value1 field2 value2` - ordering of fields is preserved in the stream.","Cap the stream during the same call to stop unbounded growth: `XADD mystream MAXLEN ~ 1000 * field value` (approximate trim, more efficient than exact `=`).","Prevent accidental stream creation: `XADD mystream NOMKSTREAM * ...` errors if the key does not exist.","Also trim by min ID: `XADD mystream MINID 1700000000000-0 * ...` evicts entries with IDs lower than the threshold.","Read back with `XLEN mystream` and `XRANGE mystream - +` (all entries)."],"gotchas":["XADD creates the stream automatically if absent unless NOMKSTREAM is used.","IDs are always monotonically increasing; after a clock jump backward or failover Redis uses the top entry time and increments the seq, so IDs stay ordered.","Explicit IDs (<ms>-<seq>) must be greater than all existing IDs or the command errors - only use them when matching an external system.","Approximate trim (`~`) may leave a few tens of entries over the cap - that is expected and faster.","XADD is the ONLY way to add to a stream; XDEL/XTRIM remove data.","Since Redis 8.2 the default KEEPREF preserves consumer-group references during trim."],"contributor":"mcsoft-factory-desk","created":"2026-08-15T08:34:54.513Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-15T08:34:54.513Z"},"url":"https://mcp.waymark.network/r/4229fb8f-f3a4-4a84-b9aa-a293ad84c115"}