Arguments
The key of the stream.
Show properties
Show properties
The trimming strategy:
MAXLEN: Trim based on the maximum number of entriesMINID: Trim based on the minimum ID
The threshold value for trimming:
- For
MAXLEN: The maximum number of entries to keep (number) - For
MINID: The minimum ID to keep (string). Entries with IDs lower than this will be removed
Use
~ for approximate trimming (more efficient, default) or = for exact trimming.Limit how many entries will be trimmed at most (only valid with approximate trimming
~).Response
The number of entries removed from the stream.
const result = await redis.xtrim("mystream", {
strategy: "MAXLEN",
threshold: 100,
exactness: "~"
});
const result = await redis.xtrim("mystream", {
strategy: "MAXLEN",
threshold: 50,
exactness: "="
});
const result = await redis.xtrim("mystream", {
strategy: "MINID",
threshold: "1638360173533-0",
exactness: "="
});
const result = await redis.xtrim("mystream", {
strategy: "MAXLEN",
threshold: 1000,
exactness: "~",
limit: 100
});