Class DefaultRedisZSet<E>
java.lang.Object
java.util.AbstractCollection<E>
org.springframework.data.redis.support.collections.AbstractRedisCollection<E>
org.springframework.data.redis.support.collections.DefaultRedisZSet<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>,BoundKeyOperations<String>,RedisCollection<E>,RedisStore,RedisZSet<E>
Default implementation for
RedisZSet. Note that the collection support works only with normal,
non-pipeline/multi-exec connections as it requires a reply to be sent right away.- Author:
- Costin Leau, Christoph Strobl, Mark Paluch, Andrey Shlykov
-
Field Summary
Fields inherited from class org.springframework.data.redis.support.collections.AbstractRedisCollection
ENCODING -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRedisZSet(String key, RedisOperations<String, E> operations) Constructs a newDefaultRedisZSetinstance with a default score of 1.DefaultRedisZSet(String key, RedisOperations<String, E> operations, double defaultScore) Constructs a newDefaultRedisZSetinstance.DefaultRedisZSet(BoundZSetOperations<String, E> boundOps) Constructs a newDefaultRedisZSetinstance with a default score of '1'.DefaultRedisZSet(BoundZSetOperations<String, E> boundOps, double defaultScore) Constructs a newDefaultRedisZSetinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds an element to the set with a default score.booleanAdds an element to the set with the given score, or updates the score if the element exists.booleanaddIfAbsent(E e, double score) Adds an element to the set with the given score if the element does not already exists.voidclear()booleandiff(Collection<? extends RedisZSet<?>> sets) Diff this set and otherRedisZSets.Diff this set and anotherRedisZSet.diffAndStore(Collection<? extends RedisZSet<?>> sets, String destKey) diffAndStore(RedisZSet<?> set, String destKey) diffWithScores(Collection<? extends RedisZSet<?>> sets) Diff this set and otherRedisZSets.diffWithScores(RedisZSet<?> set) Diff this set and anotherRedisZSet.first()Returns the first (lowest) element currently in this sorted set.Returns the default score used by this set.getType()Returns the associated Redis type.intersect(Collection<? extends RedisZSet<?>> sets) Intersect this set and otherRedisZSets.Intersect this set and anotherRedisZSet.intersectAndStore(Collection<? extends RedisZSet<?>> sets, String destKey) intersectAndStore(RedisZSet<?> set, String destKey) intersectWithScores(Collection<? extends RedisZSet<?>> sets) Intersect this set and otherRedisZSets.intersectWithScores(RedisZSet<?> set) Intersect this set and anotherRedisZSet.iterator()last()Returns the last (highest) element currently in this sorted set.Count number of elements within sorted set with value betweenRange#minandRange#maxapplying lexicographical ordering.popFirst()Removes the first (lowest) object at the top of this sorted set and returns that object as the value of this function.Removes the first (lowest) object at the top of this sorted set and returns that object as the value of this function.popLast()Removes the last (highest) object at the top of this sorted set and returns that object as the value of this function.Removes the last (highest) object at the top of this sorted set and returns that object as the value of this function.Get random element from the set.range(long start, long end) Get elements betweenstartandendfrom sorted set.rangeAndStoreByLex(String dstKey, Range<String> range, Limit limit) Store n elements atdstKey, where n =Limit.getCount(), starting atLimit.getOffset()with lexicographical ordering from ZSET at the bound key with a value betweenRange.getLowerBound()andRange.getUpperBound().rangeAndStoreByScore(String dstKey, Range<? extends Number> range, Limit limit) Store n elements atdstKey, where n =Limit.getCount(), starting atLimit.getOffset()with ordering by score from ZSET at the bound key with a score betweenRange.getLowerBound()andRange.getUpperBound().rangeByLex(Range<String> range, Limit limit) Get all elements n elements, where n =Limit.getCount(), starting atLimit.getOffset()with lexicographical ordering having a value betweenRange.getLowerBound()andRange.getUpperBound().rangeByScore(double min, double max) Get elements where score is betweenminandmaxfrom sorted set.rangeByScoreWithScores(double min, double max) rangeWithScores(long start, long end) Returns the rank (position) of the given element in the set, in ascending order.remove(long start, long end) Remove elements in range betweenstartandendfrom sorted set.booleanremoveByLex(Range<String> range) Remove all elements in range.removeByScore(double min, double max) Remove elements with scores betweenminandmaxfrom sorted set with the bound key.reverseRange(long start, long end) Get elements in range fromstarttoendfrom sorted set ordered from high to low.reverseRangeAndStoreByLex(String dstKey, Range<String> range, Limit limit) Store n elements atdstKey, where n =Limit.getCount(), starting atLimit.getOffset()with reverse lexicographical ordering from ZSET at the bound key with a value betweenRange.getLowerBound()andRange.getUpperBound().reverseRangeAndStoreByScore(String dstKey, Range<? extends Number> range, Limit limit) Store n elements atdstKey, where n =Limit.getCount(), starting atLimit.getOffset()with reverse ordering by score from ZSET at the bound key with a score betweenRange.getLowerBound()andRange.getUpperBound().reverseRangeByLex(Range<String> range, Limit limit) Get all elements n elements, where n =Limit.getCount(), starting atLimit.getOffset()with reverse lexicographical ordering having a value betweenRange.getLowerBound()andRange.getUpperBound().reverseRangeByScore(double min, double max) Get elements where score is betweenminandmaxfrom sorted set ordered from high to low.reverseRangeByScoreWithScores(double min, double max) reverseRangeWithScores(long start, long end) Returns the rank (position) of the given element in the set, in descending order.scan()scan(ScanOptions options) Returns the score of the given element.intsize()union(Collection<? extends RedisZSet<?>> sets) Union this set and otherRedisZSets.Union this set and anotherRedisZSet.unionAndStore(Collection<? extends RedisZSet<?>> sets, String destKey) unionAndStore(RedisZSet<?> set, String destKey) unionWithScores(Collection<? extends RedisZSet<?>> sets) Union this set and otherRedisZSets.unionWithScores(RedisZSet<?> set) Union this set and anotherRedisZSet.Methods inherited from class org.springframework.data.redis.support.collections.AbstractRedisCollection
addAll, checkResult, containsAll, equals, expire, expireAt, getExpire, getKey, getOperations, hashCode, persist, removeAll, rename, toStringMethods inherited from class java.util.AbstractCollection
isEmpty, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.data.redis.core.BoundKeyOperations
expiration, expire, expire, expireAt, expireAt, getExpire, getKey, persist, renameMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface org.springframework.data.redis.support.collections.RedisStore
getOperationsMethods inherited from interface org.springframework.data.redis.support.collections.RedisZSet
addIfAbsent, rangeAndStoreByLex, rangeAndStoreByScore, rangeByLex, rangeByLex, rangeByLex, reverseRangeAndStoreByLex, reverseRangeAndStoreByScore, reverseRangeByLex, reverseRangeByLex, reverseRangeByLex
-
Constructor Details
-
DefaultRedisZSet
Constructs a newDefaultRedisZSetinstance with a default score of 1.- Parameters:
key- Redis key of this set.operations-RedisOperationsfor the value type of this set.
-
DefaultRedisZSet
Constructs a newDefaultRedisZSetinstance.- Parameters:
key- Redis key of this set.operations-RedisOperationsfor the value type of this set.defaultScore-
-
DefaultRedisZSet
Constructs a newDefaultRedisZSetinstance with a default score of '1'.- Parameters:
boundOps-BoundZSetOperationsfor the value type of this set.
-
DefaultRedisZSet
Constructs a newDefaultRedisZSetinstance.- Parameters:
boundOps-BoundZSetOperationsfor the value type of this set.defaultScore-
-
-
Method Details
-
diff
Description copied from interface:RedisZSetDiff this set and anotherRedisZSet. -
diff
Description copied from interface:RedisZSetDiff this set and otherRedisZSets. -
diffWithScores
Description copied from interface:RedisZSetDiff this set and anotherRedisZSet.- Specified by:
diffWithScoresin interfaceRedisZSet<E>- Parameters:
set- must not be null.- Returns:
- a
Setcontaining the values that differ with their scores.
-
diffWithScores
Description copied from interface:RedisZSetDiff this set and otherRedisZSets.- Specified by:
diffWithScoresin interfaceRedisZSet<E>- Parameters:
sets- must not be null.- Returns:
- a
Setcontaining the values that differ with their scores.
-
diffAndStore
Description copied from interface:RedisZSetCreate a newRedisZSetby diffing this sorted set andRedisZSetand store result in destinationdestKey.- Specified by:
diffAndStorein interfaceRedisZSet<E>- Parameters:
set- must not be null.destKey- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey.
-
diffAndStore
Description copied from interface:RedisZSetCreate a newRedisZSetby diffing this sorted set and the collectionRedisZSetand store result in destinationdestKey.- Specified by:
diffAndStorein interfaceRedisZSet<E>- Parameters:
sets- must not be null.destKey- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey.
-
intersect
Description copied from interface:RedisZSetIntersect this set and anotherRedisZSet. -
intersect
Description copied from interface:RedisZSetIntersect this set and otherRedisZSets. -
intersectWithScores
Description copied from interface:RedisZSetIntersect this set and anotherRedisZSet.- Specified by:
intersectWithScoresin interfaceRedisZSet<E>- Parameters:
set- must not be null.- Returns:
- a
Setcontaining the intersecting values with their scores.
-
intersectWithScores
public Set<ZSetOperations.TypedTuple<E>> intersectWithScores(Collection<? extends RedisZSet<?>> sets) Description copied from interface:RedisZSetIntersect this set and otherRedisZSets.- Specified by:
intersectWithScoresin interfaceRedisZSet<E>- Parameters:
sets- must not be null.- Returns:
- a
Setcontaining the intersecting values with their scores.
-
intersectAndStore
Description copied from interface:RedisZSetCreate a newRedisZSetby intersecting this sorted set andRedisZSetand store result in destinationdestKey.- Specified by:
intersectAndStorein interfaceRedisZSet<E>- Parameters:
set- must not be null.destKey- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey
-
intersectAndStore
Description copied from interface:RedisZSetCreate a newRedisZSetby intersecting this sorted set and the collectionRedisZSetand store result in destinationdestKey.- Specified by:
intersectAndStorein interfaceRedisZSet<E>- Parameters:
sets- must not be null.destKey- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey
-
union
Description copied from interface:RedisZSetUnion this set and anotherRedisZSet. -
union
Description copied from interface:RedisZSetUnion this set and otherRedisZSets. -
unionWithScores
Description copied from interface:RedisZSetUnion this set and anotherRedisZSet.- Specified by:
unionWithScoresin interfaceRedisZSet<E>- Parameters:
set- must not be null.- Returns:
- a
Setcontaining the combined values with their scores.
-
unionWithScores
Description copied from interface:RedisZSetUnion this set and otherRedisZSets.- Specified by:
unionWithScoresin interfaceRedisZSet<E>- Parameters:
sets- must not be null.- Returns:
- a
Setcontaining the combined values with their scores.
-
unionAndStore
Description copied from interface:RedisZSetCreate a newRedisZSetby union this sorted set andRedisZSetand store result in destinationdestKey.- Specified by:
unionAndStorein interfaceRedisZSet<E>- Parameters:
set- must not be null.destKey- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey
-
unionAndStore
Description copied from interface:RedisZSetCreate a newRedisZSetby union this sorted set and the collectionRedisZSetand store result in destinationdestKey.- Specified by:
unionAndStorein interfaceRedisZSet<E>- Parameters:
sets- must not be null.destKey- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey
-
randomValue
Description copied from interface:RedisZSetGet random element from the set.- Specified by:
randomValuein interfaceRedisZSet<E>- Returns:
-
range
Description copied from interface:RedisZSetGet elements betweenstartandendfrom sorted set. -
reverseRange
Description copied from interface:RedisZSetGet elements in range fromstarttoendfrom sorted set ordered from high to low.- Specified by:
reverseRangein interfaceRedisZSet<E>- Returns:
-
rangeByLex
Description copied from interface:RedisZSetGet all elements n elements, where n =Limit.getCount(), starting atLimit.getOffset()with lexicographical ordering having a value betweenRange.getLowerBound()andRange.getUpperBound().- Specified by:
rangeByLexin interfaceRedisZSet<E>- Parameters:
range- must not be null.limit- can be null.- Returns:
- See Also:
-
reverseRangeByLex
Description copied from interface:RedisZSetGet all elements n elements, where n =Limit.getCount(), starting atLimit.getOffset()with reverse lexicographical ordering having a value betweenRange.getLowerBound()andRange.getUpperBound().- Specified by:
reverseRangeByLexin interfaceRedisZSet<E>- Parameters:
range- must not be null.limit- can be null.- Returns:
- See Also:
-
rangeByScore
Description copied from interface:RedisZSetGet elements where score is betweenminandmaxfrom sorted set.- Specified by:
rangeByScorein interfaceRedisZSet<E>- Returns:
-
reverseRangeByScore
Description copied from interface:RedisZSetGet elements where score is betweenminandmaxfrom sorted set ordered from high to low.- Specified by:
reverseRangeByScorein interfaceRedisZSet<E>- Returns:
-
rangeByScoreWithScores
Description copied from interface:RedisZSet- Specified by:
rangeByScoreWithScoresin interfaceRedisZSet<E>- Returns:
-
rangeWithScores
Description copied from interface:RedisZSet- Specified by:
rangeWithScoresin interfaceRedisZSet<E>- Returns:
-
reverseRangeByScoreWithScores
Description copied from interface:RedisZSet- Specified by:
reverseRangeByScoreWithScoresin interfaceRedisZSet<E>- Returns:
-
reverseRangeWithScores
Description copied from interface:RedisZSet- Specified by:
reverseRangeWithScoresin interfaceRedisZSet<E>- Returns:
-
rangeAndStoreByLex
Description copied from interface:RedisZSetStore n elements atdstKey, where n =Limit.getCount(), starting atLimit.getOffset()with lexicographical ordering from ZSET at the bound key with a value betweenRange.getLowerBound()andRange.getUpperBound().- Specified by:
rangeAndStoreByLexin interfaceRedisZSet<E>- Parameters:
dstKey- must not be null.range- must not be null.limit- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey - See Also:
-
reverseRangeAndStoreByLex
Description copied from interface:RedisZSetStore n elements atdstKey, where n =Limit.getCount(), starting atLimit.getOffset()with reverse lexicographical ordering from ZSET at the bound key with a value betweenRange.getLowerBound()andRange.getUpperBound().- Specified by:
reverseRangeAndStoreByLexin interfaceRedisZSet<E>- Parameters:
dstKey- must not be null.range- must not be null.limit- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey - See Also:
-
rangeAndStoreByScore
Description copied from interface:RedisZSetStore n elements atdstKey, where n =Limit.getCount(), starting atLimit.getOffset()with ordering by score from ZSET at the bound key with a score betweenRange.getLowerBound()andRange.getUpperBound().- Specified by:
rangeAndStoreByScorein interfaceRedisZSet<E>- Parameters:
dstKey- must not be null.range- must not be null.limit- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey - See Also:
-
reverseRangeAndStoreByScore
public RedisZSet<E> reverseRangeAndStoreByScore(String dstKey, Range<? extends Number> range, Limit limit) Description copied from interface:RedisZSetStore n elements atdstKey, where n =Limit.getCount(), starting atLimit.getOffset()with reverse ordering by score from ZSET at the bound key with a score betweenRange.getLowerBound()andRange.getUpperBound().- Specified by:
reverseRangeAndStoreByScorein interfaceRedisZSet<E>- Parameters:
dstKey- must not be null.range- must not be null.limit- must not be null.- Returns:
- a new
RedisZSetpointing atdestKey
-
remove
Description copied from interface:RedisZSetRemove elements in range betweenstartandendfrom sorted set. -
removeByLex
Description copied from interface:RedisZSetRemove all elements in range.- Specified by:
removeByLexin interfaceRedisZSet<E>- Parameters:
range- must not be null.- Returns:
thisset.
-
removeByScore
Description copied from interface:RedisZSetRemove elements with scores betweenminandmaxfrom sorted set with the bound key.- Specified by:
removeByScorein interfaceRedisZSet<E>- Returns:
thisset.
-
add
Description copied from interface:RedisZSetAdds an element to the set with a default score. Equivalent toadd(e, getDefaultScore()). The score value is implementation specific. -
add
Description copied from interface:RedisZSetAdds an element to the set with the given score, or updates the score if the element exists. -
addIfAbsent
Description copied from interface:RedisZSetAdds an element to the set with the given score if the element does not already exists.- Specified by:
addIfAbsentin interfaceRedisZSet<E>- Parameters:
e- element to addscore- element score- Returns:
- true if a new element was added, false otherwise (only the score has been updated)
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classAbstractCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractCollection<E>
-
iterator
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classAbstractCollection<E>
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-
getDefaultScore
Description copied from interface:RedisZSetReturns the default score used by this set.- Specified by:
getDefaultScorein interfaceRedisZSet<E>- Returns:
- the default score used by the implementation.
-
first
Description copied from interface:RedisZSetReturns the first (lowest) element currently in this sorted set. -
popFirst
Description copied from interface:RedisZSetRemoves the first (lowest) object at the top of this sorted set and returns that object as the value of this function. -
popFirst
Description copied from interface:RedisZSetRemoves the first (lowest) object at the top of this sorted set and returns that object as the value of this function. Blocks connection until element available ortimeoutreached. -
last
Description copied from interface:RedisZSetReturns the last (highest) element currently in this sorted set. -
popLast
Description copied from interface:RedisZSetRemoves the last (highest) object at the top of this sorted set and returns that object as the value of this function. -
popLast
Description copied from interface:RedisZSetRemoves the last (highest) object at the top of this sorted set and returns that object as the value of this function. Blocks connection until element available ortimeoutreached. -
rank
Description copied from interface:RedisZSetReturns the rank (position) of the given element in the set, in ascending order. Returns null if the element is not contained by the set. -
reverseRank
Description copied from interface:RedisZSetReturns the rank (position) of the given element in the set, in descending order. Returns null if the element is not contained by the set.- Specified by:
reverseRankin interfaceRedisZSet<E>- Parameters:
o- object- Returns:
- reverse rank of the given object
-
lexCount
Description copied from interface:RedisZSetCount number of elements within sorted set with value betweenRange#minandRange#maxapplying lexicographical ordering. -
score
Description copied from interface:RedisZSetReturns the score of the given element. Returns null if the element is not contained by the set. -
getType
Description copied from interface:BoundKeyOperationsReturns the associated Redis type.- Specified by:
getTypein interfaceBoundKeyOperations<E>- Returns:
- key type. null when used in pipeline / transaction.
-
scan
-
scan
- Parameters:
options-- Returns:
- Since:
- 1.4
-