From 274530bc8ae85ee98d7ec5455aa10441329c6679 Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Thu, 4 Dec 2025 10:09:39 +0200 Subject: [PATCH 1/8] Clarify trimming threshold definitions in xtrim.md Clarify the definition of the trimming threshold for MAXLEN and MINID, specifying that MAXLEN requires a non-negative integer. --- content/commands/xtrim.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/content/commands/xtrim.md b/content/commands/xtrim.md index 35c5b9ac0..c3e00a00a 100644 --- a/content/commands/xtrim.md +++ b/content/commands/xtrim.md @@ -111,7 +111,9 @@ The trimming strategy:
threshold -The trimming threshold. For `MAXLEN`, this is a positive integer representing the maximum number of entries. For `MINID`, this is a stream ID. +The trimming threshold: +- For `MAXLEN`: A non-negative integer representing the maximum number of entries that may remain in the stream after trimming. +- For `MINID`: A stream ID. Entries with IDs < `threshold` are trimmed, and entries with IDs ≥ `threshold` remain.
## Optional arguments @@ -144,7 +146,7 @@ If no option is specified, `KEEPREF` is used by default. Unlike the `XDELEX` and You can trim the stream using one of these strategies: -* `MAXLEN`: Evicts entries as long as the stream's length exceeds the specified `threshold`, where `threshold` is a positive integer. +* `MAXLEN`: Evicts entries as long as the stream's length exceeds the specified `threshold`, where `threshold` is a non-negative integer. * `MINID`: Evicts entries with IDs lower than `threshold`, where `threshold` is a stream ID. For example, this trims the stream to exactly the latest 1000 items: From 031ca05bda3bc30b34305084b697dc9e5c6273fc Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Thu, 4 Dec 2025 10:34:29 +0200 Subject: [PATCH 2/8] Update xadd.md --- content/commands/xadd.md | 43 +++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/content/commands/xadd.md b/content/commands/xadd.md index c93823ab5..effd09b98 100644 --- a/content/commands/xadd.md +++ b/content/commands/xadd.md @@ -116,9 +116,9 @@ linkTitle: XADD railroad_diagram: /images/railroad/xadd.svg since: 5.0.0 summary: Appends a new message to a stream. Creates the key if it doesn't exist. -syntax_fmt: "XADD key [NOMKSTREAM] [ [= | ~] threshold\n [LIMIT\_\ +syntax_fmt: "XADD key [NOMKSTREAM] [KEEPREF | DELREF | ACKED] [ [= | ~] threshold\n [LIMIT\_\ count]] <* | id> field value [field value ...]" -syntax_str: "[NOMKSTREAM] [ [= | ~] threshold [LIMIT\_count]] <* |\ +syntax_str: "[NOMKSTREAM] [KEEPREF | DELREF | ACKED] [ [= | ~] threshold [LIMIT\_count]] <* |\ \ id> field value [field value ...]" title: XADD --- @@ -168,17 +168,42 @@ If no option is specified, `KEEPREF` is used by default. Unlike the `XDELEX` and
-MAXLEN | MINID [= | ~] threshold [LIMIT count] +MAXLEN | MINID [= | ~] threshold [LIMIT count]> Trims the stream to maintain a specific size or remove old entries: -- `MAXLEN`: Limits the stream to a maximum number of entries -- `MINID`: Removes entries with IDs lower than the specified threshold (available since Redis 6.2.0) -- `=`: Exact trimming (default) -- `~`: Approximate trimming (more efficient) -- `threshold`: The maximum number of entries (for MAXLEN) or minimum ID (for MINID) -- `LIMIT count`: Limits the number of entries to examine during trimming (available since Redis 6.2.0) + +
+MAXLEN | MINID + +The trimming strategy: +- `MAXLEN`: Evicts entries as long as the stream's length exceeds the specified threshold +- `MINID`: Evicts entries with IDs lower than the specified threshold (available since Redis 6.2.0) +
+ +
+= | ~ + +The trimming operator: +- `=`: Exact trimming (default) - trims to the exact threshold +- `~`: Approximate trimming - more efficient, may leave slightly more entries than the threshold +
+ +
+threshold + +The trimming threshold: +- For `MAXLEN`: A non-negative integer representing the maximum number of entries that may remain in the stream after trimming. +- For `MINID`: A stream ID. Entries with IDs < `threshold` are trimmed, and entries with IDs ≥ `threshold` remain. +
+ +
+LIMIT count + +Limits the number of entries to examine during trimming. Available since Redis 6.2.0. When not specified, Redis uses a default value of 100 * the number of entries in a macro node. Specifying 0 disables the limiting mechanism entirely.
+
+ Each entry consists of a list of field-value pairs. Redis stores the field-value pairs in the same order you provide them. Commands that read the stream, such as [`XRANGE`]({{< relref "/commands/xrange" >}}) or [`XREAD`]({{< relref "/commands/xread" >}}), return the fields and values in exactly the same order you added them with `XADD`. From dfa605aca65f0ed8d2bf23949f1594d921d20f97 Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Thu, 4 Dec 2025 10:35:29 +0200 Subject: [PATCH 3/8] Modify XTRIM command syntax to include new options Updated syntax format and string for XTRIM command. --- content/commands/xtrim.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/commands/xtrim.md b/content/commands/xtrim.md index c3e00a00a..fcdb7cd14 100644 --- a/content/commands/xtrim.md +++ b/content/commands/xtrim.md @@ -85,8 +85,8 @@ linkTitle: XTRIM railroad_diagram: /images/railroad/xtrim.svg since: 5.0.0 summary: Deletes messages from the beginning of a stream. -syntax_fmt: "XTRIM key [= | ~] threshold [LIMIT\_count]" -syntax_str: " [= | ~] threshold [LIMIT\_count]" +syntax_fmt: "XTRIM key [= | ~] threshold [LIMIT\_count] [KEEPREF | DELREF | ACKED]" +syntax_str: " [= | ~] threshold [LIMIT\_count] [KEEPREF | DELREF | ACKED]" title: XTRIM --- From fb7c918d6e7877ff90b1c24d5df87a5e3c060c8c Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Thu, 4 Dec 2025 13:52:38 +0200 Subject: [PATCH 4/8] Enhance xtrim.md with clearer trimming strategy details Clarified the descriptions for MAXLEN and MINID trimming strategies, emphasizing the behavior of Redis during the trimming process. --- content/commands/xtrim.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/content/commands/xtrim.md b/content/commands/xtrim.md index fcdb7cd14..12347ff00 100644 --- a/content/commands/xtrim.md +++ b/content/commands/xtrim.md @@ -112,8 +112,8 @@ The trimming strategy: threshold The trimming threshold: -- For `MAXLEN`: A non-negative integer representing the maximum number of entries that may remain in the stream after trimming. -- For `MINID`: A stream ID. Entries with IDs < `threshold` are trimmed, and entries with IDs ≥ `threshold` remain. +- For `MAXLEN`: `threshold` is a non-negative integer specifying the maximum number of entries that may remain in the stream after trimming. Redis enforces this by removing the oldest entries — that is, the entries with the lowest stream IDs — so that only the newest entries remain. +- For `MINID`: `threshold` is a stream ID. All entries whose IDs are less than `threshold` are trimmed. All entries with IDs greater than or equal to `threshold` are kept. ## Optional arguments @@ -144,11 +144,6 @@ If no option is specified, `KEEPREF` is used by default. Unlike the `XDELEX` and - `ACKED`: When trimming, only removes entries that were read and acknowledged by all consumer groups. Note that if the number of referenced entries is larger than `MAXLEN`, trimming will still stop at the limit. -You can trim the stream using one of these strategies: - -* `MAXLEN`: Evicts entries as long as the stream's length exceeds the specified `threshold`, where `threshold` is a non-negative integer. -* `MINID`: Evicts entries with IDs lower than `threshold`, where `threshold` is a stream ID. - For example, this trims the stream to exactly the latest 1000 items: ``` From e382ab9d4ae2b35af85689ba966ae29a0b385eae Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Thu, 4 Dec 2025 13:54:10 +0200 Subject: [PATCH 5/8] Improve clarity of trimming threshold descriptions Clarify the explanation of trimming thresholds for MAXLEN and MINID in xadd.md. --- content/commands/xadd.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/commands/xadd.md b/content/commands/xadd.md index effd09b98..980d8e24b 100644 --- a/content/commands/xadd.md +++ b/content/commands/xadd.md @@ -192,8 +192,8 @@ The trimming operator: threshold The trimming threshold: -- For `MAXLEN`: A non-negative integer representing the maximum number of entries that may remain in the stream after trimming. -- For `MINID`: A stream ID. Entries with IDs < `threshold` are trimmed, and entries with IDs ≥ `threshold` remain. +- For `MAXLEN`: `threshold` is a non-negative integer specifying the maximum number of entries that may remain in the stream after trimming. Redis enforces this by removing the oldest entries — that is, the entries with the lowest stream IDs — so that only the newest entries are kept. +- For `MINID`: `threshold` is a stream ID. All entries whose IDs are less than `threshold` are trimmed. All entries with IDs greater than or equal to `threshold` are kept.
From 632413822f1e8018b8c9a725d255e5a241f61881 Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Thu, 4 Dec 2025 13:54:47 +0200 Subject: [PATCH 6/8] Update xtrim.md for MAXLEN threshold description Clarified the description of the 'MAXLEN' threshold in the xtrim command documentation. --- content/commands/xtrim.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/commands/xtrim.md b/content/commands/xtrim.md index 12347ff00..e313b3d3f 100644 --- a/content/commands/xtrim.md +++ b/content/commands/xtrim.md @@ -112,7 +112,7 @@ The trimming strategy: threshold The trimming threshold: -- For `MAXLEN`: `threshold` is a non-negative integer specifying the maximum number of entries that may remain in the stream after trimming. Redis enforces this by removing the oldest entries — that is, the entries with the lowest stream IDs — so that only the newest entries remain. +- For `MAXLEN`: `threshold` is a non-negative integer specifying the maximum number of entries that may remain in the stream after trimming. Redis enforces this by removing the oldest entries — that is, the entries with the lowest stream IDs — so that only the newest entries are kept. - For `MINID`: `threshold` is a stream ID. All entries whose IDs are less than `threshold` are trimmed. All entries with IDs greater than or equal to `threshold` are kept.
From 9a85b0263e296192abe9e369d7554f18704acfaa Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Thu, 4 Dec 2025 13:55:23 +0200 Subject: [PATCH 7/8] Fix formatting in xtrim.md for trimming threshold Updated formatting for clarity in xtrim command documentation. --- content/commands/xtrim.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/commands/xtrim.md b/content/commands/xtrim.md index e313b3d3f..143e8d546 100644 --- a/content/commands/xtrim.md +++ b/content/commands/xtrim.md @@ -112,7 +112,7 @@ The trimming strategy: threshold The trimming threshold: -- For `MAXLEN`: `threshold` is a non-negative integer specifying the maximum number of entries that may remain in the stream after trimming. Redis enforces this by removing the oldest entries — that is, the entries with the lowest stream IDs — so that only the newest entries are kept. +- For `MAXLEN`: `threshold` is a non-negative integer specifying the maximum number of entries that may remain in the stream after trimming. Redis enforces this by removing the oldest entries - that is, the entries with the lowest stream IDs - so that only the newest entries are kept. - For `MINID`: `threshold` is a stream ID. All entries whose IDs are less than `threshold` are trimmed. All entries with IDs greater than or equal to `threshold` are kept. From dfdf747ce90ea10e618301eee861e6699d4902c0 Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Thu, 4 Dec 2025 13:56:04 +0200 Subject: [PATCH 8/8] Fix formatting of threshold explanation in xadd.md --- content/commands/xadd.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/commands/xadd.md b/content/commands/xadd.md index 980d8e24b..226307128 100644 --- a/content/commands/xadd.md +++ b/content/commands/xadd.md @@ -192,7 +192,7 @@ The trimming operator: threshold The trimming threshold: -- For `MAXLEN`: `threshold` is a non-negative integer specifying the maximum number of entries that may remain in the stream after trimming. Redis enforces this by removing the oldest entries — that is, the entries with the lowest stream IDs — so that only the newest entries are kept. +- For `MAXLEN`: `threshold` is a non-negative integer specifying the maximum number of entries that may remain in the stream after trimming. Redis enforces this by removing the oldest entries - that is, the entries with the lowest stream IDs - so that only the newest entries are kept. - For `MINID`: `threshold` is a stream ID. All entries whose IDs are less than `threshold` are trimmed. All entries with IDs greater than or equal to `threshold` are kept.