diff --git a/src/main/java/io/lettuce/core/XTrimArgs.java b/src/main/java/io/lettuce/core/XTrimArgs.java index 65308460d2..2a71b1ecaf 100644 --- a/src/main/java/io/lettuce/core/XTrimArgs.java +++ b/src/main/java/io/lettuce/core/XTrimArgs.java @@ -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; @@ -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; diff --git a/src/test/java/io/lettuce/core/commands/StreamCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/StreamCommandIntegrationTests.java index 9334bca6c1..fe2606ced7 100644 --- a/src/test/java/io/lettuce/core/commands/StreamCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/StreamCommandIntegrationTests.java @@ -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