Skip to content

Commit

Permalink
Allow zero maxlen/limit using XTRIM #2250
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Nov 22, 2022
1 parent e4229b6 commit 1ca86f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/XTrimArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static XTrimArgs minId(String minid) {
*/
public XTrimArgs maxlen(long maxlen) {

LettuceAssert.isTrue(maxlen > 0, "Maxlen must be greater 0");
LettuceAssert.isTrue(maxlen >= 0, "Maxlen must be greater or equal to 0");

this.maxlen = maxlen;
return this;
Expand Down Expand Up @@ -111,7 +111,7 @@ public XTrimArgs minId(String minid) {
*/
public XTrimArgs limit(long limit) {

LettuceAssert.isTrue(limit > 0, "Limit must be greater 0");
LettuceAssert.isTrue(limit >= 0, "Limit must be greater 0");

this.limit = limit;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ void xtrim() {
redis.xtrim(key, true, 8);

assertThat(redis.xlen(key)).isLessThanOrEqualTo(10);

redis.xtrim(key, XTrimArgs.Builder.maxlen(0).limit(0).approximateTrimming());

assertThat(redis.xlen(key)).isLessThanOrEqualTo(10);
}

@Test
Expand Down

0 comments on commit 1ca86f4

Please sign in to comment.