Redis Commands
- A
- B
- Client
-
Cluster
- Cluster-addslots
- Cluster-addslotsrange
- Cluster-bumpepoch
- Cluster-count-failure-reports
- Cluster-countkeysinslot
- Cluster-delslots
- Cluster-delslotsrange
- Cluster-failover
- Cluster-flushslots
- Cluster-forget
- Cluster-getkeysinslot
- Cluster-help
- Cluster-info
- Cluster-keyslot
- Cluster-links
- Cluster-meet
- Cluster-myid
- Cluster-myshardid
- Cluster-nodes
- Cluster-replicas
- Cluster-replicate
- Cluster-reset
- Cluster-saveconfig
- Cluster-set-config-epoch
- Cluster-setslot
- Cluster-shards
- Cluster-slaves
- Cluster-slots
- Cluster
- Command
- Config
- D
- E
- F
- G
- H
- I
- K
- L
- M
- O
- P
- Q
- R
- S1
- S2
- T
- U
- W
- X
- Z1
- Z2
Docs > Redis Commands > X > Xtrim
XTRIM
trims the stream by evicting older entries (entries with lower IDs) if needed.
Trimming the stream can be done using one of these strategies:
MAXLEN
: Evicts entries as long as the stream's length exceeds the specifiedthreshold
, wherethreshold
is a positive integer.MINID
: Evicts entries with IDs lower thanthreshold
, wherethreshold
is a stream ID.
For example, this will trim the stream to exactly the latest 1000 items:
XTRIM mystream MAXLEN 1000
Whereas in this example, all entries that have an ID lower than 649085820-0 will be evicted:
XTRIM mystream MINID 649085820
By default, or when provided with the optional =
argument, the command performs exact trimming.
Depending on the strategy, exact trimming means:
MAXLEN
: the trimmed stream's length will be exactly the minimum between its original length and the specifiedthreshold
.MINID
: the oldest ID in the stream will be exactly the maximum between its original oldest ID and the specifiedthreshold
.
Nearly exact trimming