All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.data.redis.core.BoundZSetOperations Maven / Gradle / Ivy

There is a newer version: 3.2.5
Show newest version
/*
 * Copyright 2011-2022 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
 *
 *      https://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 java.time.Duration;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
import org.springframework.data.redis.connection.RedisZSetCommands.Weights;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

/**
 * ZSet (or SortedSet) operations bound to a certain key.
 *
 * @author Costin Leau
 * @author Christoph Strobl
 * @author Mark Paluch
 * @author Wongoo (望哥)
 * @author Andrey Shlykov
 */
public interface BoundZSetOperations extends BoundKeyOperations {

	/**
	 * Add {@code value} to a sorted set at the bound key, or update its {@code score} if it already exists.
	 *
	 * @param value the value.
	 * @param score the score.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZADD
	 */
	@Nullable
	Boolean add(V value, double score);

	/**
	 * Add {@code value} to a sorted set at the bound key if it does not already exists.
	 *
	 * @param value the value.
	 * @param score the score.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.5
	 * @see Redis Documentation: ZADD NX
	 */
	@Nullable
	Boolean addIfAbsent(V value, double score);

	/**
	 * Add {@code tuples} to a sorted set at the bound key, or update its {@code score} if it already exists.
	 *
	 * @param tuples must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZADD
	 */
	@Nullable
	Long add(Set> tuples);

	/**
	 * Add {@code tuples} to a sorted set at the bound key if it does not already exists.
	 *
	 * @param tuples must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.5
	 * @see Redis Documentation: ZADD NX
	 */
	@Nullable
	Long addIfAbsent(Set> tuples);

	/**
	 * Remove {@code values} from sorted set. Return number of removed elements.
	 *
	 * @param values must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZREM
	 */
	@Nullable
	Long remove(Object... values);

	/**
	 * Increment the score of element with {@code value} in sorted set by {@code increment}.
	 *
	 * @param value the value.
	 * @param delta the delta to add. Can be negative.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZINCRBY
	 */
	@Nullable
	Double incrementScore(V value, double delta);

	/**
	 * Get random element from set at the bound key.
	 *
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZRANDMEMBER
	 */
	V randomMember();

	/**
	 * Get {@code count} distinct random elements from set at the bound key.
	 *
	 * @param count number of members to return.
	 * @return empty {@link Set} if {@code key} does not exist.
	 * @throws IllegalArgumentException if count is negative.
	 * @since 2.6
	 * @see Redis Documentation: ZRANDMEMBER
	 */
	@Nullable
	Set distinctRandomMembers(long count);

	/**
	 * Get {@code count} random elements from set at the bound key.
	 *
	 * @param count number of members to return.
	 * @return empty {@link List} if {@code key} does not exist or {@literal null} when used in pipeline / transaction.
	 * @throws IllegalArgumentException if count is negative.
	 * @since 2.6
	 * @see Redis Documentation: ZRANDMEMBER
	 */
	@Nullable
	List randomMembers(long count);

	/**
	 * Get random element with its score from set at the bound key.
	 *
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZRANDMEMBER
	 */
	TypedTuple randomMemberWithScore();

	/**
	 * Get {@code count} distinct random elements with their score from set at the bound key.
	 *
	 * @param count number of members to return.
	 * @return empty {@link Set} if {@code key} does not exist.
	 * @throws IllegalArgumentException if count is negative.
	 * @since 2.6
	 * @see Redis Documentation: ZRANDMEMBER
	 */
	@Nullable
	Set> distinctRandomMembersWithScore(long count);

	/**
	 * Get {@code count} random elements with their score from set at the bound key.
	 *
	 * @param count number of members to return.
	 * @return empty {@link List} if {@code key} does not exist or {@literal null} when used in pipeline / transaction.
	 * @throws IllegalArgumentException if count is negative.
	 * @since 2.6
	 * @see Redis Documentation: ZRANDMEMBER
	 */
	@Nullable
	List> randomMembersWithScore(long count);

	/**
	 * Determine the index of element with {@code value} in a sorted set.
	 *
	 * @param o the value.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZRANK
	 */
	@Nullable
	Long rank(Object o);

	/**
	 * Determine the index of element with {@code value} in a sorted set when scored high to low.
	 *
	 * @param o the value.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZREVRANK
	 */
	@Nullable
	Long reverseRank(Object o);

	/**
	 * Get elements between {@code start} and {@code end} from sorted set.
	 *
	 * @param start
	 * @param end
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZRANGE
	 */
	@Nullable
	Set range(long start, long end);

	/**
	 * Get set of {@link Tuple}s between {@code start} and {@code end} from sorted set.
	 *
	 * @param start
	 * @param end
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZRANGE
	 */
	@Nullable
	Set> rangeWithScores(long start, long end);

	/**
	 * Get elements where score is between {@code min} and {@code max} from sorted set.
	 *
	 * @param min
	 * @param max
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZRANGEBYSCORE
	 */
	@Nullable
	Set rangeByScore(double min, double max);

	/**
	 * Get set of {@link Tuple}s where score is between {@code min} and {@code max} from sorted set.
	 *
	 * @param min
	 * @param max
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZRANGEBYSCORE
	 */
	@Nullable
	Set> rangeByScoreWithScores(double min, double max);

	/**
	 * Get elements in range from {@code start} to {@code end} from sorted set ordered from high to low.
	 *
	 * @param start
	 * @param end
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZREVRANGE
	 */
	@Nullable
	Set reverseRange(long start, long end);

	/**
	 * Get set of {@link Tuple}s in range from {@code start} to {@code end} from sorted set ordered from high to low.
	 *
	 * @param start
	 * @param end
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZREVRANGE
	 */
	@Nullable
	Set> reverseRangeWithScores(long start, long end);

	/**
	 * Get elements where score is between {@code min} and {@code max} from sorted set ordered from high to low.
	 *
	 * @param min
	 * @param max
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZREVRANGEBYSCORE
	 */
	@Nullable
	Set reverseRangeByScore(double min, double max);

	/**
	 * Get set of {@link Tuple} where score is between {@code min} and {@code max} from sorted set ordered from high to
	 * low.
	 *
	 * @param min
	 * @param max
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZREVRANGEBYSCORE
	 */
	@Nullable
	Set> reverseRangeByScoreWithScores(double min, double max);

	/**
	 * Count number of elements within sorted set with scores between {@code min} and {@code max}.
	 *
	 * @param min
	 * @param max
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZCOUNT
	 */
	@Nullable
	Long count(double min, double max);

	/**
	 * 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 2.4
	 * @see Redis Documentation: ZLEXCOUNT
	 */
	@Nullable
	Long lexCount(Range range);

	/**
	 * Remove and return the value with its score having the lowest score from sorted set at the bound key.
	 *
	 * @return {@literal null} when the sorted set is empty or used in pipeline / transaction.
	 * @see Redis Documentation: ZPOPMIN
	 * @since 2.6
	 */
	@Nullable
	TypedTuple popMin();

	/**
	 * Remove and return {@code count} values with their score having the lowest score from sorted set at the bound key.
	 *
	 * @param count number of elements to pop.
	 * @return {@literal null} when the sorted set is empty or used in pipeline / transaction.
	 * @see Redis Documentation: ZPOPMIN
	 * @since 2.6
	 */
	@Nullable
	Set> popMin(long count);

	/**
	 * Remove and return the value with its score having the lowest score from sorted set at the bound key. Blocks
	 * connection until element available or {@code timeout} reached.
	 *
	 * @param timeout
	 * @param unit must not be {@literal null}.
	 * @return can be {@literal null}.
	 * @see Redis Documentation: BZPOPMIN
	 * @since 2.6
	 */
	@Nullable
	TypedTuple popMin(long timeout, TimeUnit unit);

	/**
	 * Remove and return the value with its score having the lowest score from sorted set at the bound key. Blocks
	 * connection until element available or {@code timeout} reached.
	 *
	 * @param timeout must not be {@literal null}.
	 * @return can be {@literal null}.
	 * @throws IllegalArgumentException if the timeout is {@literal null} or negative.
	 * @see Redis Documentation: BZPOPMIN
	 * @since 2.6
	 */
	@Nullable
	default TypedTuple popMin(Duration timeout) {

		Assert.notNull(timeout, "Timeout must not be null");
		Assert.isTrue(!timeout.isNegative(), "Timeout must not be negative");

		return popMin(TimeoutUtils.toSeconds(timeout), TimeUnit.SECONDS);
	}

	/**
	 * Remove and return the value with its score having the highest score from sorted set at the bound key.
	 *
	 * @return {@literal null} when the sorted set is empty or used in pipeline / transaction.
	 * @see Redis Documentation: ZPOPMAX
	 * @since 2.6
	 */
	@Nullable
	TypedTuple popMax();

	/**
	 * Remove and return {@code count} values with their score having the highest score from sorted set at the bound key.
	 *
	 * @param count number of elements to pop.
	 * @return {@literal null} when the sorted set is empty or used in pipeline / transaction.
	 * @see Redis Documentation: ZPOPMAX
	 * @since 2.6
	 */
	@Nullable
	Set> popMax(long count);

	/**
	 * Remove and return the value with its score having the highest score from sorted set at the bound key. Blocks
	 * connection until element available or {@code timeout} reached.
	 *
	 * @param timeout
	 * @param unit must not be {@literal null}.
	 * @return can be {@literal null}.
	 * @see Redis Documentation: BZPOPMAX
	 * @since 2.6
	 */
	@Nullable
	TypedTuple popMax(long timeout, TimeUnit unit);

	/**
	 * Remove and return the value with its score having the highest score from sorted set at the bound key. Blocks
	 * connection until element available or {@code timeout} reached.
	 *
	 * @param timeout must not be {@literal null}.
	 * @return can be {@literal null}.
	 * @throws IllegalArgumentException if the timeout is {@literal null} or negative.
	 * @see Redis Documentation: BZPOPMAX
	 * @since 2.6
	 */
	@Nullable
	default TypedTuple popMax(Duration timeout) {

		Assert.notNull(timeout, "Timeout must not be null");
		Assert.isTrue(!timeout.isNegative(), "Timeout must not be negative");

		return popMax(TimeoutUtils.toSeconds(timeout), TimeUnit.SECONDS);
	}

	/**
	 * Returns the number of elements of the sorted set stored with given the bound key.
	 *
	 * @see #zCard()
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZCARD
	 */
	@Nullable
	Long size();

	/**
	 * Get the size of sorted set with the bound key.
	 *
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 1.3
	 * @see Redis Documentation: ZCARD
	 */
	@Nullable
	Long zCard();

	/**
	 * Get the score of element with {@code value} from sorted set with key the bound key.
	 *
	 * @param o the value.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZSCORE
	 */
	@Nullable
	Double score(Object o);

	/**
	 * Get the scores of elements with {@code values} from sorted set with key the bound key.
	 *
	 * @param o the values.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZMSCORE
	 * @since 2.6
	 */
	@Nullable
	List score(Object... o);

	/**
	 * Remove elements in range between {@code start} and {@code end} from sorted set with the bound key.
	 *
	 * @param start
	 * @param end
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZREMRANGEBYRANK
	 */
	@Nullable
	Long removeRange(long start, long end);

	/**
	 * 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 2.5
	 * @see Redis Documentation: ZREMRANGEBYLEX
	 */
	@Nullable
	Long removeRangeByLex(Range range);

	/**
	 * Remove elements with scores between {@code min} and {@code max} from sorted set with the bound key.
	 *
	 * @param min
	 * @param max
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZREMRANGEBYSCORE
	 */
	@Nullable
	Long removeRangeByScore(double min, double max);

	/**
	 * Union sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
	 *
	 * @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 {@literal null} when used in pipeline / transaction.
	 * @since 2.1
	 * @see Redis Documentation: ZUNIONSTORE
	 */
	@Nullable
	Long unionAndStore(Collection otherKeys, K destKey, Aggregate aggregate, Weights weights);

	/**
	 * Diff sorted {@code sets}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZDIFF
	 */
	@Nullable
	default Set difference(K otherKey) {
		return difference(Collections.singleton(otherKey));
	}

	/**
	 * Diff sorted {@code sets}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZDIFF
	 */
	@Nullable
	Set difference(Collection otherKeys);

	/**
	 * Diff sorted {@code sets}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZDIFF
	 */
	@Nullable
	default Set> differenceWithScores(K otherKey) {
		return differenceWithScores(Collections.singleton(otherKey));
	}

	/**
	 * Diff sorted {@code sets}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZDIFF
	 */
	@Nullable
	Set> differenceWithScores(Collection otherKeys);

	/**
	 * Diff sorted {@code sets} and store result in destination {@code destKey}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @param destKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZDIFFSTORE
	 */
	@Nullable
	default Long differenceAndStore(K otherKey, K destKey) {
		return differenceAndStore(Collections.singleton(otherKey), destKey);
	}

	/**
	 * Diff sorted {@code sets} and store result in destination {@code destKey}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @param destKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZDIFFSTORE
	 */
	@Nullable
	Long differenceAndStore(Collection otherKeys, K destKey);

	/**
	 * Intersect sorted {@code sets}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZINTER
	 */
	@Nullable
	default Set intersect(K otherKey) {
		return intersect(Collections.singleton(otherKey));
	}

	/**
	 * Intersect sorted {@code sets}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZINTER
	 */
	@Nullable
	Set intersect(Collection otherKeys);

	/**
	 * Intersect sorted {@code sets}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZINTER
	 */
	@Nullable
	default Set> intersectWithScores(K otherKey) {
		return intersectWithScores(Collections.singleton(otherKey));
	}

	/**
	 * Intersect sorted {@code sets}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZINTER
	 */
	@Nullable
	Set> intersectWithScores(Collection otherKeys);

	/**
	 * Intersect sorted {@code sets}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @param aggregate must not be {@literal null}.
	 * @param weights must not be {@literal null}.
	 * @return
	 * @since 2.6
	 * @see Redis Documentation: ZINTER
	 */
	@Nullable
	Set> intersectWithScores(Collection otherKeys, Aggregate aggregate, Weights weights);

	/**
	 * Intersect sorted sets at the bound key and {@code otherKey} and store result in destination {@code destKey}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @param destKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZINTERSTORE
	 */
	@Nullable
	Long intersectAndStore(K otherKey, K destKey);

	/**
	 * Intersect sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @param destKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZINTERSTORE
	 */
	@Nullable
	Long intersectAndStore(Collection otherKeys, K destKey);

	/**
	 * Intersect sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @param destKey must not be {@literal null}.
	 * @param aggregate must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.1
	 * @see Redis Documentation: ZINTERSTORE
	 */
	@Nullable
	Long intersectAndStore(Collection otherKeys, K destKey, Aggregate aggregate);

	/**
	 * Intersect sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
	 *
	 * @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 {@literal null} when used in pipeline / transaction.
	 * @since 2.1
	 * @see Redis Documentation: ZINTERSTORE
	 */
	@Nullable
	Long intersectAndStore(Collection otherKeys, K destKey, Aggregate aggregate, Weights weights);

	/**
	 * Union sorted {@code sets}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZUNION
	 */
	@Nullable
	default Set union(K otherKey) {
		return union(Collections.singleton(otherKey));
	}

	/**
	 * Union sorted {@code sets}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZUNION
	 */
	@Nullable
	Set union(Collection otherKeys);

	/**
	 * Union sorted {@code sets}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZUNION
	 */
	@Nullable
	default Set> unionWithScores(K otherKey) {
		return unionWithScores(Collections.singleton(otherKey));
	}

	/**
	 * Union sorted {@code sets}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZUNION
	 */
	@Nullable
	Set> unionWithScores(Collection otherKeys);

	/**
	 * Union sorted sets at the bound key and {@code otherKeys}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @param aggregate must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZUNION
	 */
	@Nullable
	default Set> unionWithScores(Collection otherKeys, Aggregate aggregate) {
		return unionWithScores(otherKeys, aggregate, Weights.fromSetCount(1 + otherKeys.size()));
	}

	/**
	 * Union sorted {@code sets}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @param aggregate must not be {@literal null}.
	 * @param weights must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.6
	 * @see Redis Documentation: ZUNION
	 */
	@Nullable
	Set> unionWithScores(Collection otherKeys, Aggregate aggregate, Weights weights);

	/**
	 * Union sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
	 *
	 * @param otherKey must not be {@literal null}.
	 * @param destKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZUNIONSTORE
	 */
	@Nullable
	Long unionAndStore(K otherKey, K destKey);

	/**
	 * Union sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @param destKey must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @see Redis Documentation: ZUNIONSTORE
	 */
	@Nullable
	Long unionAndStore(Collection otherKeys, K destKey);

	/**
	 * Union sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
	 *
	 * @param otherKeys must not be {@literal null}.
	 * @param destKey must not be {@literal null}.
	 * @param aggregate must not be {@literal null}.
	 * @return {@literal null} when used in pipeline / transaction.
	 * @since 2.1
	 * @see Redis Documentation: ZUNIONSTORE
	 */
	@Nullable
	Long unionAndStore(Collection otherKeys, K destKey, Aggregate aggregate);

	/**
	 * Iterate over elements in zset at the bound key. 
* Important: Call {@link Cursor#close()} when done to avoid resource leak. * * @param options * @return * @since 1.4 */ Cursor> scan(ScanOptions options); /** * Get all elements with lexicographical ordering with a value between {@link Range#getMin()} and * {@link Range#getMax()}. * * @param range must not be {@literal null}. * @return {@literal null} when used in pipeline / transaction. * @since 1.7 * @see Redis Documentation: ZRANGEBYLEX */ @Nullable default Set rangeByLex(Range range) { return rangeByLex(range, Limit.unlimited()); } /** * 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#getMin()} and * {@link Range#getMax()}. * * @param range must not be {@literal null}. * @param limit can be {@literal null}. * @return {@literal null} when used in pipeline / transaction. * @since 1.7 * @see Redis Documentation: ZRANGEBYLEX */ @Nullable Set rangeByLex(Range range, Limit limit); /** * Get all elements with reverse lexicographical ordering with a value between {@link Range#getMin()} and * {@link Range#getMax()}. * * @param range must not be {@literal null}. * @return {@literal null} when used in pipeline / transaction. * @since 2.4 * @see Redis Documentation: ZREVRANGEBYLEX */ @Nullable default Set reverseRangeByLex(Range range) { return reverseRangeByLex(range, Limit.unlimited()); } /** * 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#getMin()} and * {@link Range#getMax()}. * * @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 */ @Nullable Set reverseRangeByLex(Range range, Limit limit); /** * @return never {@literal null}. */ RedisOperations getOperations(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy