diff --git a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java index c3f464274..6043185e0 100644 --- a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java @@ -1536,7 +1536,7 @@ public interface StringRedisConnection extends RedisConnection { * @return {@literal null} when used in pipeline / transaction. * @since 2.4 * @see Redis Documentation: ZLEXCOUNT - * @see RedisZSetCommands#zLexCount(byte[], Range) + * @see RedisZSetCommands#zLexCount(byte[], org.springframework.data.domain.Range) */ @Nullable Long zLexCount(String key, org.springframework.data.domain.Range range); @@ -1926,7 +1926,7 @@ public interface StringRedisConnection extends RedisConnection { * @return * @since 1.6 * @see Redis Documentation: ZRANGEBYLEX - * @see RedisZSetCommands#zRangeByLex(byte[], Range) + * @see RedisZSetCommands#zRangeByLex(byte[], org.springframework.data.domain.Range) */ Set zRangeByLex(String key, org.springframework.data.domain.Range range); @@ -1940,7 +1940,7 @@ public interface StringRedisConnection extends RedisConnection { * @return * @since 1.6 * @see Redis Documentation: ZRANGEBYLEX - * @see RedisZSetCommands#zRangeByLex(byte[], Range, Limit) + * @see RedisZSetCommands#zRangeByLex(byte[], org.springframework.data.domain.Range, org.springframework.data.redis.connection.Limit) */ Set zRangeByLex(String key, org.springframework.data.domain.Range range, org.springframework.data.redis.connection.Limit limit); @@ -1966,7 +1966,7 @@ public interface StringRedisConnection extends RedisConnection { * @return * @since 2.4 * @see Redis Documentation: ZREVRANGEBYLEX - * @see RedisZSetCommands#zRevRangeByLex(byte[], Range) + * @see RedisZSetCommands#zRevRangeByLex(byte[], org.springframework.data.domain.Range) */ default Set zRevRangeByLex(String key, org.springframework.data.domain.Range range) { return zRevRangeByLex(key, range, org.springframework.data.redis.connection.Limit.unlimited()); @@ -1982,7 +1982,7 @@ public interface StringRedisConnection extends RedisConnection { * @return * @since 2.4 * @see Redis Documentation: ZREVRANGEBYLEX - * @see RedisZSetCommands#zRevRangeByLex(byte[], Range, Limit) + * @see RedisZSetCommands#zRevRangeByLex(byte[], org.springframework.data.domain.Range, org.springframework.data.redis.connection.Limit) */ Set zRevRangeByLex(String key, org.springframework.data.domain.Range range, org.springframework.data.redis.connection.Limit limit); diff --git a/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java b/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java index 28c802eb7..295b775d8 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java @@ -301,6 +301,22 @@ public interface BoundZSetOperations extends BoundKeyOperations { * @return {@literal null} when used in pipeline / transaction. * @since 2.4 * @see Redis Documentation: ZLEXCOUNT + * @deprecated since 3.0. Please use {@link #lexCount(Range)} instead. + */ + @Nullable + @Deprecated(since = "3.0", forRemoval = true) + default Long lexCount(org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return lexCount(range.toRange()); + } + + /** + * Count number of elements within sorted set with value between {@code Range#min} and {@code Range#max} applying + * lexicographical ordering. + * + * @param range must not be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZLEXCOUNT */ @Nullable Long lexCount(Range range); @@ -470,6 +486,21 @@ public interface BoundZSetOperations extends BoundKeyOperations { * @return {@literal null} when used in pipeline / transaction. * @since 2.5 * @see Redis Documentation: ZREMRANGEBYLEX + * @deprecated since 3.0. Please use {@link #removeRangeByLex(Range)}. + */ + @Nullable + @Deprecated(since = "3.0", forRemoval = true) + default Long removeRangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return removeRangeByLex(range.toRange()); + } + + /** + * Remove elements in {@link Range} from sorted set with the bound key. + * + * @param range must not be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZREMRANGEBYLEX */ @Nullable Long removeRangeByLex(Range range); @@ -812,6 +843,22 @@ public interface BoundZSetOperations extends BoundKeyOperations { * @return {@literal null} when used in pipeline / transaction. * @since 1.7 * @see Redis Documentation: ZRANGEBYLEX + * @deprecated since 3.0. Please use {@link #rangeByLex(Range)} instead. + */ + @Nullable + @Deprecated(since = "3.0", forRemoval = true) + default Set rangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return rangeByLex(range.toRange()); + } + + /** + * Get all elements with lexicographical ordering with a value between {@link Range#getLowerBound()} and + * {@link Range#getUpperBound()}. + * + * @param range must not be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZRANGEBYLEX */ @Nullable default Set rangeByLex(Range range) { @@ -828,6 +875,24 @@ public interface BoundZSetOperations extends BoundKeyOperations { * @return {@literal null} when used in pipeline / transaction. * @since 1.7 * @see Redis Documentation: ZRANGEBYLEX + * @deprecated since 3.0. Please use {@link #rangeByLex(Range, Limit)} instead. + */ + @Nullable + @Deprecated(since = "3.0", forRemoval = true) + default Set rangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range, Limit limit) { + return rangeByLex(range.toRange(), limit); + } + + /** + * Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at + * {@link Limit#getOffset()} with lexicographical ordering having a value between {@link Range#getLowerBound()} and + * {@link Range#getUpperBound()}. + * + * @param range must not be {@literal null}. + * @param limit can be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZRANGEBYLEX */ @Nullable Set rangeByLex(Range range, Limit limit); @@ -840,6 +905,22 @@ public interface BoundZSetOperations extends BoundKeyOperations { * @return {@literal null} when used in pipeline / transaction. * @since 2.4 * @see Redis Documentation: ZREVRANGEBYLEX + * @deprecated since 3.0. Please use {@link #reverseRangeByLex(Range)} instead. + */ + @Nullable + @Deprecated(since = "3.0", forRemoval = true) + default Set reverseRangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return reverseRangeByLex(range); + } + + /** + * Get all elements with reverse lexicographical ordering with a value between {@link Range#getLowerBound()} and + * {@link Range#getUpperBound()}. + * + * @param range must not be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZREVRANGEBYLEX */ @Nullable default Set reverseRangeByLex(Range range) { @@ -856,6 +937,24 @@ public interface BoundZSetOperations extends BoundKeyOperations { * @return {@literal null} when used in pipeline / transaction. * @since 2.4 * @see Redis Documentation: ZREVRANGEBYLEX + * @deprecated since 3.0. Please use {@link #reverseRangeByLex(Range, Limit)} instead. + */ + @Nullable + @Deprecated(since = "3.0", forRemoval = true) + default Set reverseRangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range, Limit limit) { + return reverseRangeByLex(range.toRange(), limit); + } + + /** + * Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at + * {@link Limit#getOffset()} with reverse lexicographical ordering having a value between + * {@link Range#getLowerBound()} and {@link Range#getUpperBound()}. + * + * @param range must not be {@literal null}. + * @param limit can be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZREVRANGEBYLEX */ @Nullable Set reverseRangeByLex(Range range, Limit limit); diff --git a/src/main/java/org/springframework/data/redis/core/ZSetOperations.java b/src/main/java/org/springframework/data/redis/core/ZSetOperations.java index 4ad626238..0b203a0e7 100644 --- a/src/main/java/org/springframework/data/redis/core/ZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/ZSetOperations.java @@ -410,6 +410,23 @@ public interface ZSetOperations { * @return {@literal null} when used in pipeline / transaction. * @since 2.4 * @see Redis Documentation: ZLEXCOUNT + * @deprecated since 3.0. Please use #lexCount(Range) instead. + */ + @Nullable + @Deprecated(since = "3.0", forRemoval = true) + default Long lexCount(K key, org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return lexCount(key, range.toRange()); + } + + /** + * Count number of elements within sorted set with value between {@link Range#getLowerBound()} and + * {@link Range#getUpperBound()} applying lexicographical ordering. + * + * @param key must not be {@literal null}. + * @param range must not be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZLEXCOUNT */ @Nullable Long lexCount(K key, Range range); @@ -593,9 +610,25 @@ public interface ZSetOperations { * @return {@literal null} when used in pipeline / transaction. * @since 2.5 * @see Redis Documentation: ZREMRANGEBYLEX + * @deprecated since 3.0. Please use {@link #removeRangeByLex(Object, Range)} instead; */ @Nullable - Long removeRangeByLex(K key, org.springframework.data.domain.Range range); + @Deprecated(since = "3.0", forRemoval = true) + default Long removeRangeByLex(K key, org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return removeRangeByLex(key, range.toRange()); + } + + /** + * Remove elements in {@link Range} from sorted set with {@literal key}. + * + * @param key must not be {@literal null}. + * @param range must not be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZREMRANGEBYLEX + */ + @Nullable + Long removeRangeByLex(K key, Range range); /** * Remove elements with scores between {@code min} and {@code max} from sorted set with {@code key}. @@ -961,23 +994,42 @@ public interface ZSetOperations { /** * Get all elements with lexicographical ordering from {@literal ZSET} at {@code key} with a value between - * {@link Range#getMin()} and {@link Range#getMax()}. + * {@link org.springframework.data.redis.connection.RedisZSetCommands.Range#getMin()} and + * {@link org.springframework.data.redis.connection.RedisZSetCommands.Range#getMax()}. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return {@literal null} when used in pipeline / transaction. * @since 1.7 * @see Redis Documentation: ZRANGEBYLEX + * @deprecated since 3.0. Please use {@link #rangeByLex(Object, Range)} instead. */ @Nullable - default Set rangeByLex(K key, org.springframework.data.domain.Range range) { + @Deprecated(since = "3.0", forRemoval = true) + default Set rangeByLex(K key, org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return rangeByLex(key, range.toRange()); + } + + /** + * Get all elements with lexicographical ordering from {@literal ZSET} at {@code key} with a value between + * {@link Range#getLowerBound()} and {@link Range#getUpperBound()}. + * + * @param key must not be {@literal null}. + * @param range must not be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZRANGEBYLEX + */ + @Nullable + default Set rangeByLex(K key, Range range) { return rangeByLex(key, range, Limit.unlimited()); } /** * Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at * {@link Limit#getOffset()} with lexicographical ordering from {@literal ZSET} at {@code key} with a value between - * {@link Range#getMin()} and {@link Range#getMax()}. + * {@link org.springframework.data.redis.connection.RedisZSetCommands.Range#getMin()} and + * {@link org.springframework.data.redis.connection.RedisZSetCommands.Range#getMax()}. * * @param key must not be {@literal null} * @param range must not be {@literal null}. @@ -985,29 +1037,88 @@ public interface ZSetOperations { * @return {@literal null} when used in pipeline / transaction. * @since 1.7 * @see Redis Documentation: ZRANGEBYLEX + * @deprecated since 3.0. Please use {@link #rangeByLex(Object, Range, Limit)} instead. */ @Nullable - Set rangeByLex(K key, org.springframework.data.domain.Range range, Limit limit); + @Deprecated(since = "3.0", forRemoval = true) + default Set rangeByLex(K key, org.springframework.data.redis.connection.RedisZSetCommands.Range range, + Limit limit) { + return rangeByLex(key, range.toRange(), limit); + } + + /** + * Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at + * {@link Limit#getOffset()} with lexicographical ordering from {@literal ZSET} at {@code key} with a value between + * {@link Range#getLowerBound()} and {@link Range#getUpperBound()}. + * + * @param key must not be {@literal null} + * @param range must not be {@literal null}. + * @param limit can be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZRANGEBYLEX + */ + @Nullable + Set rangeByLex(K key, Range range, Limit limit); /** * Get all elements with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value between - * {@link Range#getMin()} and {@link Range#getMax()}. + * {@link org.springframework.data.redis.connection.RedisZSetCommands.Range#getMin()} and + * {@link org.springframework.data.redis.connection.RedisZSetCommands.Range#getMax()}. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return {@literal null} when used in pipeline / transaction. * @since 2.4 * @see Redis Documentation: ZREVRANGEBYLEX + * @deprecated since 3.0. Please use {@link #reverseRangeByLex(Object, Range)} */ @Nullable - default Set reverseRangeByLex(K key, org.springframework.data.domain.Range range) { + @Deprecated(since = "3.0", forRemoval = true) + default Set reverseRangeByLex(K key, org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return reverseRangeByLex(key, range.toRange()); + } + + /** + * Get all elements with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value between + * {@link Range#getLowerBound()} and {@link Range#getUpperBound()}. + * + * @param key must not be {@literal null}. + * @param range must not be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 3.0 + * @see Redis Documentation: ZREVRANGEBYLEX + */ + @Nullable + default Set reverseRangeByLex(K key, Range range) { return reverseRangeByLex(key, range, Limit.unlimited()); } /** * Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at * {@link Limit#getOffset()} with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value - * between {@link Range#getMin()} and {@link Range#getMax()}. + * between {@link org.springframework.data.redis.connection.RedisZSetCommands.Range#getMin()} and + * {@link org.springframework.data.redis.connection.RedisZSetCommands.Range#getMax()}. + * + * @param key must not be {@literal null} + * @param range must not be {@literal null}. + * @param limit can be {@literal null}. + * @return {@literal null} when used in pipeline / transaction. + * @since 2.4 + * @see Redis Documentation: ZREVRANGEBYLEX + * @deprecated since 3.0. Please use {@link #reverseRangeByLex(Object, Range, Limit)} instead. + */ + @Nullable + @Deprecated(since = "3.0", forRemoval = true) + default Set reverseRangeByLex(K key, org.springframework.data.redis.connection.RedisZSetCommands.Range range, + Limit limit) { + return reverseRangeByLex(key, range.toRange(), limit); + } + + /** + * Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at + * {@link Limit#getOffset()} with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value + * between {@link Range#getLowerBound()} and {@link Range#getUpperBound()}. * * @param key must not be {@literal null} * @param range must not be {@literal null}. @@ -1017,7 +1128,7 @@ public interface ZSetOperations { * @see Redis Documentation: ZREVRANGEBYLEX */ @Nullable - Set reverseRangeByLex(K key, org.springframework.data.domain.Range range, Limit limit); + Set reverseRangeByLex(K key, Range range, Limit limit); /** * @return never {@literal null}. diff --git a/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java b/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java index 1377914de..b22c2fb85 100644 --- a/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java +++ b/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java @@ -270,6 +270,21 @@ public interface RedisZSet extends RedisCollection, Set { * @return * @see BoundZSetOperations#rangeByLex(Range) * @since 1.7 + * @deprecated since 3.0. Please use {@link #rangeByLex(Range)} instead. + */ + @Deprecated(since = "3.0", forRemoval = true) + default Set rangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return rangeByLex(range.toRange()); + } + + /** + * Get all elements with lexicographical ordering with a value between {@link Range#getLowerBound()} and + * {@link Range#getUpperBound()}. + * + * @param range must not be {@literal null}. + * @return + * @see BoundZSetOperations#rangeByLex(Range) + * @since 3.0 */ default Set rangeByLex(Range range) { return rangeByLex(range, Limit.unlimited()); @@ -285,6 +300,23 @@ public interface RedisZSet extends RedisCollection, Set { * @return * @since 1.7 * @see BoundZSetOperations#rangeByLex(Range, Limit) + * @deprecated since 3.0. Please use {@link #rangeByLex(Range, Limit)} instead. + */ + @Deprecated(since = "3.0", forRemoval = true) + default Set rangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range, Limit limit) { + return rangeByLex(range.toRange(), limit); + } + + /** + * Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at + * {@link Limit#getOffset()} with lexicographical ordering having a value between {@link Range#getLowerBound()} and + * {@link Range#getUpperBound()}. + * + * @param range must not be {@literal null}. + * @param limit can be {@literal null}. + * @return + * @since 3.0 + * @see BoundZSetOperations#rangeByLex(Range, Limit) */ Set rangeByLex(Range range, Limit limit); @@ -296,6 +328,21 @@ public interface RedisZSet extends RedisCollection, Set { * @return * @since 2.4 * @see BoundZSetOperations#reverseRangeByLex(Range) + * @deprecated since 3.0. Please use {@link #reverseRangeByLex(Range, Limit)} instead. + */ + @Deprecated(since = "3.0", forRemoval = true) + default Set reverseRangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range) { + return reverseRangeByLex(range.toRange()); + } + + /** + * Get all elements with reverse lexicographical ordering with a value between {@link Range#getLowerBound()} and + * {@link Range#getUpperBound()}. + * + * @param range must not be {@literal null}. + * @return + * @since 3.0 + * @see BoundZSetOperations#reverseRangeByLex(Range) */ default Set reverseRangeByLex(Range range) { return reverseRangeByLex(range, Limit.unlimited()); @@ -311,6 +358,24 @@ public interface RedisZSet extends RedisCollection, Set { * @return * @since 2.4 * @see BoundZSetOperations#reverseRangeByLex(Range, Limit) + * @deprecated since 3.0. Please use {@link #reverseRangeByLex(Range, Limit)} instead. + */ + @Deprecated(since = "3.0", forRemoval = true) + default Set reverseRangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range range, + Limit limit) { + return reverseRangeByLex(range.toRange(), limit); + } + + /** + * Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at + * {@link Limit#getOffset()} with reverse lexicographical ordering having a value between + * {@link Range#getLowerBound()} and {@link Range#getUpperBound()}. + * + * @param range must not be {@literal null}. + * @param limit can be {@literal null}. + * @return + * @since 3.0 + * @see BoundZSetOperations#reverseRangeByLex(Range, Limit) */ Set reverseRangeByLex(Range range, Limit limit);