Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2017-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.core;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.Collection;
import org.springframework.data.domain.Range;
import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
import org.springframework.data.redis.connection.RedisZSetCommands.Weights;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
/**
* Redis ZSet/sorted set specific operations.
*
* @author Mark Paluch
* @author Christoph Strobl
* @see Redis Documentation: Sorted Set Commands
* @since 2.0
*/
public interface ReactiveZSetOperations {
/**
* Add {@code value} to a sorted set at {@code key}, or update its {@code score} if it already exists.
*
* @param key must not be {@literal null}.
* @param score the score.
* @param value the value.
* @return
* @see Redis Documentation: ZADD
*/
Mono add(K key, V value, double score);
/**
* Add {@code tuples} to a sorted set at {@code key}, or update their score if it already exists.
*
* @param key must not be {@literal null}.
* @param tuples the score.
* @return
* @see Redis Documentation: ZADD
*/
Mono addAll(K key, Collection> tuples);
/**
* Remove {@code values} from sorted set. Return number of removed elements.
*
* @param key must not be {@literal null}.
* @param values must not be {@literal null}.
* @return
* @see Redis Documentation: ZREM
*/
Mono remove(K key, Object... values);
/**
* Increment the score of element with {@code value} in sorted set by {@code increment}.
*
* @param key must not be {@literal null}.
* @param delta
* @param value the value.
* @return
* @see Redis Documentation: ZINCRBY
*/
Mono incrementScore(K key, V value, double delta);
/**
* Determine the index of element with {@code value} in a sorted set.
*
* @param key must not be {@literal null}.
* @param o the value.
* @return
* @see Redis Documentation: ZRANK
*/
Mono rank(K key, Object o);
/**
* Determine the index of element with {@code value} in a sorted set when scored high to low.
*
* @param key must not be {@literal null}.
* @param o the value.
* @return
* @see Redis Documentation: ZREVRANK
*/
Mono reverseRank(K key, Object o);
/**
* Get elements between {@code start} and {@code end} from sorted set.
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @see Redis Documentation: ZRANGE
*/
Flux range(K key, Range range);
/**
* Get set of {@link Tuple}s between {@code start} and {@code end} from sorted set.
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @see Redis Documentation: ZRANGE
*/
Flux> rangeWithScores(K key, Range range);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set.
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @see Redis Documentation: ZRANGEBYSCORE
*/
Flux rangeByScore(K key, Range range);
/**
* Get set of {@link Tuple}s where score is between {@code min} and {@code max} from sorted set.
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @see Redis Documentation: ZRANGEBYSCORE
*/
Flux> rangeByScoreWithScores(K key, Range range);
/**
* Get elements in range from {@code start} to {@code end} where score is between {@code min} and {@code max} from
* sorted set.
*
* @param key must not be {@literal null}.
* @param range
* @param limit
* @return
* @see Redis Documentation: ZRANGEBYSCORE
*/
Flux rangeByScore(K key, Range range, Limit limit);
/**
* Get set of {@link Tuple}s in range from {@code start} to {@code end} where score is between {@code min} and
* {@code max} from sorted set.
*
* @param key
* @param range
* @param limit
* @return
* @see Redis Documentation: ZRANGEBYSCORE
*/
Flux> rangeByScoreWithScores(K key, Range range, Limit limit);
/**
* Get elements in range from {@code start} to {@code end} from sorted set ordered from high to low.
*
* @param key must not be {@literal null}.
* @param range
* @return
* @see Redis Documentation: ZREVRANGE
*/
Flux reverseRange(K key, Range range);
/**
* Get set of {@link Tuple}s in range from {@code start} to {@code end} from sorted set ordered from high to low.
*
* @param key must not be {@literal null}.
* @param range
* @return
* @see Redis Documentation: ZREVRANGE
*/
Flux> reverseRangeWithScores(K key, Range range);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set ordered from high to low.
*
* @param key must not be {@literal null}.
* @param range
* @return
* @see Redis Documentation: ZREVRANGE
*/
Flux reverseRangeByScore(K key, Range range);
/**
* Get set of {@link Tuple} where score is between {@code min} and {@code max} from sorted set ordered from high to
* low.
*
* @param key must not be {@literal null}.
* @param range
* @return
* @see Redis Documentation: ZREVRANGEBYSCORE
*/
Flux> reverseRangeByScoreWithScores(K key, Range range);
/**
* Get elements in range from {@code start} to {@code end} where score is between {@code min} and {@code max} from
* sorted set ordered high -> low.
*
* @param key must not be {@literal null}.
* @param range
* @param limit
* @return
* @see Redis Documentation: ZREVRANGEBYSCORE
*/
Flux reverseRangeByScore(K key, Range range, Limit limit);
/**
* Get set of {@link Tuple} in range from {@code start} to {@code end} where score is between {@code min} and
* {@code max} from sorted set ordered high -> low.
*
* @param key must not be {@literal null}.
* @param range
* @param limit
* @return
* @see Redis Documentation: ZREVRANGEBYSCORE
*/
Flux> reverseRangeByScoreWithScores(K key, Range range, Limit limit);
/**
* Use a {@link Flux} to iterate over entries in the sorted set at {@code key}. The resulting {@link Flux} acts as a
* cursor and issues {@code ZSCAN} commands itself as long as the subscriber signals demand.
*
* @param key must not be {@literal null}.
* @return the {@link Flux} emitting the {@literal values} one by one or an {@link Flux#empty() empty Flux} if none
* exist.
* @throws IllegalArgumentException when given {@code key} is {@literal null}.
* @see Redis Documentation: ZSCAN
* @since 2.1
*/
default Flux> scan(K key) {
return scan(key, ScanOptions.NONE);
}
/**
* Use a {@link Flux} to iterate over entries in the sorted set at {@code key} given {@link ScanOptions}. The
* resulting {@link Flux} acts as a cursor and issues {@code ZSCAN} commands itself as long as the subscriber signals
* demand.
*
* @param key must not be {@literal null}.
* @param options must not be {@literal null}. Use {@link ScanOptions#NONE} instead.
* @return the {@link Flux} emitting the {@literal values} one by one or an {@link Flux#empty() empty Flux} if none
* exist.
* @throws IllegalArgumentException when one of the required arguments is {@literal null}.
* @see Redis Documentation: ZSCAN
* @since 2.1
*/
Flux> scan(K key, ScanOptions options);
/**
* Count number of elements within sorted set with scores between {@code min} and {@code max}.
*
* @param key must not be {@literal null}.
* @param range
* @return
* @see Redis Documentation: ZCOUNT
*/
Mono count(K key, Range range);
/**
* Returns the number of elements of the sorted set stored with given {@code key}.
*
* @param key
* @return
* @see Redis Documentation: ZCARD
*/
Mono size(K key);
/**
* Get the score of element with {@code value} from sorted set with key {@code key}.
*
* @param key must not be {@literal null}.
* @param o the value.
* @return
* @see Redis Documentation: ZSCORE
*/
Mono score(K key, Object o);
/**
* Remove elements in range between {@code start} and {@code end} from sorted set with {@code key}.
*
* @param key must not be {@literal null}.
* @param range
* @return
* @see Redis Documentation: ZREMRANGEBYRANK
*/
Mono removeRange(K key, Range range);
/**
* Remove elements with scores between {@code min} and {@code max} from sorted set with {@code key}.
*
* @param key must not be {@literal null}.
* @param range
* @return
* @see Redis Documentation: ZREMRANGEBYSCORE
*/
Mono removeRangeByScore(K key, Range range);
/**
* Union sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see Redis Documentation: ZUNIONSTORE
*/
Mono unionAndStore(K key, K otherKey, K destKey);
/**
* Union sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see Redis Documentation: ZUNIONSTORE
*/
Mono unionAndStore(K key, Collection otherKeys, K destKey);
/**
* Union sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @param aggregate must not be {@literal null}.
* @return
* @since 2.1
* @see Redis Documentation: ZUNIONSTORE
*/
default Mono unionAndStore(K key, Collection otherKeys, K destKey, Aggregate aggregate) {
return unionAndStore(key, otherKeys, destKey, aggregate, Weights.fromSetCount(1 + otherKeys.size()));
}
/**
* Union sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @param aggregate must not be {@literal null}.
* @param weights must not be {@literal null}.
* @return
* @since 2.1
* @see Redis Documentation: ZUNIONSTORE
*/
Mono unionAndStore(K key, Collection otherKeys, K destKey, Aggregate aggregate, Weights weights);
/**
* Intersect sorted sets at {@code key} and {@code otherKey} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see Redis Documentation: ZINTERSTORE
*/
Mono intersectAndStore(K key, K otherKey, K destKey);
/**
* Intersect sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see Redis Documentation: ZINTERSTORE
*/
Mono intersectAndStore(K key, Collection otherKeys, K destKey);
/**
* Intersect sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @param aggregate must not be {@literal null}.
* @return
* @since 2.1
* @see Redis Documentation: ZINTERSTORE
*/
default Mono intersectAndStore(K key, Collection otherKeys, K destKey, Aggregate aggregate) {
return intersectAndStore(key, otherKeys, destKey, aggregate, Weights.fromSetCount(1 + otherKeys.size()));
}
/**
* Intersect sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @param aggregate must not be {@literal null}.
* @param weights must not be {@literal null}.
* @return
* @since 2.1
* @see Redis Documentation: ZINTERSTORE
*/
Mono intersectAndStore(K key, Collection otherKeys, K destKey, Aggregate aggregate, Weights weights);
/**
* 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}.
* @see Redis Documentation: ZRANGEBYLEX
*/
Flux rangeByLex(K key, Range range);
/**
* 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
* @see Redis Documentation: ZRANGEBYLEX
*/
Flux 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#getLowerBound()} and {@link Range#getUpperBound()}.
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @see Redis Documentation: ZREVRANGEBYLEX
*/
Flux reverseRangeByLex(K key, Range range);
/**
* 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}.
* @param limit can be {@literal null}.
* @return
* @see Redis Documentation: ZREVRANGEBYLEX
*/
Flux reverseRangeByLex(K key, Range range, Limit limit);
/**
* Removes the given {@literal key}.
*
* @param key must not be {@literal null}.
*/
Mono delete(K key);
}