method

RedisClient.xtrim

key: KeyLike,
strategy: 'MAXLEN' | 'MINID' | 'maxlen' | 'minid',
threshold: string | number,
...options: string | number[]
): Promise<number>;

Trim a stream to a given size or minimum ID

@param key

The stream key

@param strategy

MAXLEN (trim by length) or MINID (trim by minimum ID)

@param threshold

The threshold value, or "~"/"=" followed by the threshold in options

@param options

Optional ~/= operator (as the threshold), actual threshold, and LIMIT count

@returns

Promise that resolves with the number of entries deleted

await redis.xtrim("mystream", "MAXLEN", 1000);
await redis.xtrim("mystream", "MAXLEN", "~", 1000);

Referenced types

type KeyLike = string | ArrayBufferView | Blob