Reintroduce and deprecate methods using ZSetCommand.Range.

Provide a smoother upgrade experience.
Fix some javadoc along the way.

See: #2288
Original Pull Request: #2292
This commit is contained in:
Christoph Strobl
2022-05-20 12:38:59 +02:00
parent 21c147d2aa
commit 2a4cf7a644
4 changed files with 289 additions and 14 deletions

View File

@@ -1536,7 +1536,7 @@ public interface StringRedisConnection extends RedisConnection {
* @return {@literal null} when used in pipeline / transaction.
* @since 2.4
* @see <a href="https://redis.io/commands/zlexcount">Redis Documentation: ZLEXCOUNT</a>
* @see RedisZSetCommands#zLexCount(byte[], Range)
* @see RedisZSetCommands#zLexCount(byte[], org.springframework.data.domain.Range)
*/
@Nullable
Long zLexCount(String key, org.springframework.data.domain.Range<String> range);
@@ -1926,7 +1926,7 @@ public interface StringRedisConnection extends RedisConnection {
* @return
* @since 1.6
* @see <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
* @see RedisZSetCommands#zRangeByLex(byte[], Range)
* @see RedisZSetCommands#zRangeByLex(byte[], org.springframework.data.domain.Range)
*/
Set<String> zRangeByLex(String key, org.springframework.data.domain.Range<String> range);
@@ -1940,7 +1940,7 @@ public interface StringRedisConnection extends RedisConnection {
* @return
* @since 1.6
* @see <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
* @see RedisZSetCommands#zRangeByLex(byte[], Range, Limit)
* @see RedisZSetCommands#zRangeByLex(byte[], org.springframework.data.domain.Range, org.springframework.data.redis.connection.Limit)
*/
Set<String> zRangeByLex(String key, org.springframework.data.domain.Range<String> range,
org.springframework.data.redis.connection.Limit limit);
@@ -1966,7 +1966,7 @@ public interface StringRedisConnection extends RedisConnection {
* @return
* @since 2.4
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
* @see RedisZSetCommands#zRevRangeByLex(byte[], Range)
* @see RedisZSetCommands#zRevRangeByLex(byte[], org.springframework.data.domain.Range)
*/
default Set<String> zRevRangeByLex(String key, org.springframework.data.domain.Range<String> 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 <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
* @see RedisZSetCommands#zRevRangeByLex(byte[], Range, Limit)
* @see RedisZSetCommands#zRevRangeByLex(byte[], org.springframework.data.domain.Range, org.springframework.data.redis.connection.Limit)
*/
Set<String> zRevRangeByLex(String key, org.springframework.data.domain.Range<String> range,
org.springframework.data.redis.connection.Limit limit);

View File

@@ -301,6 +301,22 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
* @return {@literal null} when used in pipeline / transaction.
* @since 2.4
* @see <a href="https://redis.io/commands/zlexcount">Redis Documentation: ZLEXCOUNT</a>
* @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 <a href="https://redis.io/commands/zlexcount">Redis Documentation: ZLEXCOUNT</a>
*/
@Nullable
Long lexCount(Range<String> range);
@@ -470,6 +486,21 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
* @return {@literal null} when used in pipeline / transaction.
* @since 2.5
* @see <a href="https://redis.io/commands/zremrangebylex">Redis Documentation: ZREMRANGEBYLEX</a>
* @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 <a href="https://redis.io/commands/zremrangebylex">Redis Documentation: ZREMRANGEBYLEX</a>
*/
@Nullable
Long removeRangeByLex(Range<String> range);
@@ -812,6 +843,22 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
* @return {@literal null} when used in pipeline / transaction.
* @since 1.7
* @see <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #rangeByLex(Range)} instead.
*/
@Nullable
@Deprecated(since = "3.0", forRemoval = true)
default Set<V> 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 <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
@Nullable
default Set<V> rangeByLex(Range<String> range) {
@@ -828,6 +875,24 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
* @return {@literal null} when used in pipeline / transaction.
* @since 1.7
* @see <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #rangeByLex(Range, Limit)} instead.
*/
@Nullable
@Deprecated(since = "3.0", forRemoval = true)
default Set<V> 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 <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
@Nullable
Set<V> rangeByLex(Range<String> range, Limit limit);
@@ -840,6 +905,22 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
* @return {@literal null} when used in pipeline / transaction.
* @since 2.4
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #reverseRangeByLex(Range)} instead.
*/
@Nullable
@Deprecated(since = "3.0", forRemoval = true)
default Set<V> 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 <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
*/
@Nullable
default Set<V> reverseRangeByLex(Range<String> range) {
@@ -856,6 +937,24 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
* @return {@literal null} when used in pipeline / transaction.
* @since 2.4
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #reverseRangeByLex(Range, Limit)} instead.
*/
@Nullable
@Deprecated(since = "3.0", forRemoval = true)
default Set<V> 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 <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
*/
@Nullable
Set<V> reverseRangeByLex(Range<String> range, Limit limit);

View File

@@ -410,6 +410,23 @@ public interface ZSetOperations<K, V> {
* @return {@literal null} when used in pipeline / transaction.
* @since 2.4
* @see <a href="https://redis.io/commands/zlexcount">Redis Documentation: ZLEXCOUNT</a>
* @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 <a href="https://redis.io/commands/zlexcount">Redis Documentation: ZLEXCOUNT</a>
*/
@Nullable
Long lexCount(K key, Range<String> range);
@@ -593,9 +610,25 @@ public interface ZSetOperations<K, V> {
* @return {@literal null} when used in pipeline / transaction.
* @since 2.5
* @see <a href="https://redis.io/commands/zremrangebylex">Redis Documentation: ZREMRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #removeRangeByLex(Object, Range)} instead;
*/
@Nullable
Long removeRangeByLex(K key, org.springframework.data.domain.Range<String> 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 <a href="https://redis.io/commands/zremrangebylex">Redis Documentation: ZREMRANGEBYLEX</a>
*/
@Nullable
Long removeRangeByLex(K key, Range<String> range);
/**
* Remove elements with scores between {@code min} and {@code max} from sorted set with {@code key}.
@@ -961,23 +994,42 @@ public interface ZSetOperations<K, V> {
/**
* 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 <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #rangeByLex(Object, Range)} instead.
*/
@Nullable
default Set<V> rangeByLex(K key, org.springframework.data.domain.Range<String> range) {
@Deprecated(since = "3.0", forRemoval = true)
default Set<V> 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 <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
@Nullable
default Set<V> rangeByLex(K key, Range<String> 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<K, V> {
* @return {@literal null} when used in pipeline / transaction.
* @since 1.7
* @see <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #rangeByLex(Object, Range, Limit)} instead.
*/
@Nullable
Set<V> rangeByLex(K key, org.springframework.data.domain.Range<String> range, Limit limit);
@Deprecated(since = "3.0", forRemoval = true)
default Set<V> 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 <a href="https://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
@Nullable
Set<V> rangeByLex(K key, Range<String> 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 <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #reverseRangeByLex(Object, Range)}
*/
@Nullable
default Set<V> reverseRangeByLex(K key, org.springframework.data.domain.Range<String> range) {
@Deprecated(since = "3.0", forRemoval = true)
default Set<V> 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 <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
*/
@Nullable
default Set<V> reverseRangeByLex(K key, Range<String> 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 <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
* @deprecated since 3.0. Please use {@link #reverseRangeByLex(Object, Range, Limit)} instead.
*/
@Nullable
@Deprecated(since = "3.0", forRemoval = true)
default Set<V> 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<K, V> {
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
*/
@Nullable
Set<V> reverseRangeByLex(K key, org.springframework.data.domain.Range<String> range, Limit limit);
Set<V> reverseRangeByLex(K key, Range<String> range, Limit limit);
/**
* @return never {@literal null}.

View File

@@ -270,6 +270,21 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @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<E> 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<E> rangeByLex(Range<String> range) {
return rangeByLex(range, Limit.unlimited());
@@ -285,6 +300,23 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @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<E> 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<E> rangeByLex(Range<String> range, Limit limit);
@@ -296,6 +328,21 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @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<E> 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<E> reverseRangeByLex(Range<String> range) {
return reverseRangeByLex(range, Limit.unlimited());
@@ -311,6 +358,24 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @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<E> 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<E> reverseRangeByLex(Range<String> range, Limit limit);