public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements RedisZSet<E>
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.ENCODING
Constructor and Description |
---|
DefaultRedisZSet(BoundZSetOperations<String,E> boundOps)
Constructs a new
DefaultRedisZSet instance with a default score of '1'. |
DefaultRedisZSet(BoundZSetOperations<String,E> boundOps,
double defaultScore)
Constructs a new
DefaultRedisZSet instance. |
DefaultRedisZSet(String key,
RedisOperations<String,E> operations)
Constructs a new
DefaultRedisZSet instance with a default score of 1. |
DefaultRedisZSet(String key,
RedisOperations<String,E> operations,
double defaultScore)
Constructs a new
DefaultRedisZSet instance. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e)
Adds an element to the set with a default score.
|
boolean |
add(E e,
double score)
Adds an element to the set with the given score, or updates the score if the element exists.
|
boolean |
addIfAbsent(E e,
double score)
Adds an element to the set with the given score if the element does not already exists.
|
void |
clear() |
boolean |
contains(Object o) |
Set<E> |
diff(Collection<? extends RedisZSet<?>> sets)
Diff this set and other
RedisZSet s. |
Set<E> |
diff(RedisZSet<?> set)
Diff this set and another
RedisZSet . |
RedisZSet<E> |
diffAndStore(Collection<? extends RedisZSet<?>> sets,
String destKey)
|
RedisZSet<E> |
diffAndStore(RedisZSet<?> set,
String destKey)
|
Set<ZSetOperations.TypedTuple<E>> |
diffWithScores(Collection<? extends RedisZSet<?>> sets)
Diff this set and other
RedisZSet s. |
Set<ZSetOperations.TypedTuple<E>> |
diffWithScores(RedisZSet<?> set)
Diff this set and another
RedisZSet . |
E |
first()
Returns the first (lowest) element currently in this sorted set.
|
Double |
getDefaultScore()
Returns the default score used by this set.
|
DataType |
getType()
Returns the associated Redis type.
|
Set<E> |
intersect(Collection<? extends RedisZSet<?>> sets)
Intersect this set and other
RedisZSet s. |
Set<E> |
intersect(RedisZSet<?> set)
Intersect this set and another
RedisZSet . |
RedisZSet<E> |
intersectAndStore(Collection<? extends RedisZSet<?>> sets,
String destKey)
|
RedisZSet<E> |
intersectAndStore(RedisZSet<?> set,
String destKey)
|
Set<ZSetOperations.TypedTuple<E>> |
intersectWithScores(Collection<? extends RedisZSet<?>> sets)
Intersect this set and other
RedisZSet s. |
Set<ZSetOperations.TypedTuple<E>> |
intersectWithScores(RedisZSet<?> set)
Intersect this set and another
RedisZSet . |
Iterator<E> |
iterator() |
E |
last()
Returns the last (highest) element currently in this sorted set.
|
Long |
lexCount(RedisZSetCommands.Range range)
Count number of elements within sorted set with value between
Range#min and Range#max applying
lexicographical ordering. |
E |
popFirst()
Removes the first (lowest) object at the top of this sorted set and returns that object as the value of this
function.
|
E |
popFirst(long timeout,
TimeUnit unit)
Removes the first (lowest) object at the top of this sorted set and returns that object as the value of this
function.
|
E |
popLast()
Removes the last (highest) object at the top of this sorted set and returns that object as the value of this
function.
|
E |
popLast(long timeout,
TimeUnit unit)
Removes the last (highest) object at the top of this sorted set and returns that object as the value of this
function.
|
E |
randomValue()
Get random element from the set.
|
Set<E> |
range(long start,
long end)
Get elements between
start and end from sorted set. |
Set<E> |
rangeByLex(RedisZSetCommands.Range range,
RedisZSetCommands.Limit limit)
Get all elements n elements, where n =
RedisZSetCommands.Limit.getCount() , starting at
RedisZSetCommands.Limit.getOffset() with lexicographical ordering having a value between RedisZSetCommands.Range.getMin() and
RedisZSetCommands.Range.getMax() . |
Set<E> |
rangeByScore(double min,
double max)
Get elements where score is between
min and max from sorted set. |
Set<ZSetOperations.TypedTuple<E>> |
rangeByScoreWithScores(double min,
double max)
Get set of
RedisZSetCommands.Tuple s where score is between min and max from sorted set. |
Set<ZSetOperations.TypedTuple<E>> |
rangeWithScores(long start,
long end)
Get set of
RedisZSetCommands.Tuple s between start and end from sorted set. |
Long |
rank(Object o)
Returns the rank (position) of the given element in the set, in ascending order.
|
RedisZSet<E> |
remove(long start,
long end)
Remove elements in range between
start and end from sorted set. |
boolean |
remove(Object o) |
Set<E> |
removeByLex(RedisZSetCommands.Range range)
Remove all elements in range.
|
RedisZSet<E> |
removeByScore(double min,
double max)
Remove elements with scores between
min and max from sorted set with the bound key. |
Set<E> |
reverseRange(long start,
long end)
Get elements in range from
start to end from sorted set ordered from high to low. |
Set<E> |
reverseRangeByLex(RedisZSetCommands.Range range,
RedisZSetCommands.Limit limit)
Get all elements n elements, where n =
RedisZSetCommands.Limit.getCount() , starting at
RedisZSetCommands.Limit.getOffset() with reverse lexicographical ordering having a value between RedisZSetCommands.Range.getMin() and
RedisZSetCommands.Range.getMax() . |
Set<E> |
reverseRangeByScore(double min,
double max)
Get elements where score is between
min and max from sorted set ordered from high to low. |
Set<ZSetOperations.TypedTuple<E>> |
reverseRangeByScoreWithScores(double min,
double max)
Get set of
RedisZSetCommands.Tuple s where score is between min and max from sorted set
ordered from high to low. |
Set<ZSetOperations.TypedTuple<E>> |
reverseRangeWithScores(long start,
long end)
Get set of
RedisZSetCommands.Tuple s in range from start to end from sorted set ordered from
high to low. |
Long |
reverseRank(Object o)
Returns the rank (position) of the given element in the set, in descending order.
|
Cursor<E> |
scan() |
Cursor<ZSetOperations.TypedTuple<E>> |
scan(ScanOptions options) |
Double |
score(Object o)
Returns the score of the given element.
|
int |
size() |
Set<E> |
union(Collection<? extends RedisZSet<?>> sets)
Union this set and other
RedisZSet s. |
Set<E> |
union(RedisZSet<?> set)
Union this set and another
RedisZSet . |
RedisZSet<E> |
unionAndStore(Collection<? extends RedisZSet<?>> sets,
String destKey)
|
RedisZSet<E> |
unionAndStore(RedisZSet<?> set,
String destKey)
|
Set<ZSetOperations.TypedTuple<E>> |
unionWithScores(Collection<? extends RedisZSet<?>> sets)
Union this set and other
RedisZSet s. |
Set<ZSetOperations.TypedTuple<E>> |
unionWithScores(RedisZSet<?> set)
Union this set and another
RedisZSet . |
addAll, checkResult, containsAll, equals, expire, expireAt, getExpire, getKey, getOperations, hashCode, persist, removeAll, rename, toString
isEmpty, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addIfAbsent, create, create, rangeByLex, reverseRangeByLex
getOperations
expire, expire, expireAt, expireAt, getExpire, getKey, persist, rename
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public DefaultRedisZSet(String key, RedisOperations<String,E> operations)
DefaultRedisZSet
instance with a default score of 1.key
- Redis key of this set.operations
- RedisOperations
for the value type of this set.public DefaultRedisZSet(String key, RedisOperations<String,E> operations, double defaultScore)
DefaultRedisZSet
instance.key
- Redis key of this set.operations
- RedisOperations
for the value type of this set.defaultScore
- public DefaultRedisZSet(BoundZSetOperations<String,E> boundOps)
DefaultRedisZSet
instance with a default score of '1'.boundOps
- BoundZSetOperations
for the value type of this set.public DefaultRedisZSet(BoundZSetOperations<String,E> boundOps, double defaultScore)
DefaultRedisZSet
instance.boundOps
- BoundZSetOperations
for the value type of this set.defaultScore
- public Set<E> diff(RedisZSet<?> set)
RedisZSet
RedisZSet
.public Set<E> diff(Collection<? extends RedisZSet<?>> sets)
RedisZSet
RedisZSet
s.public Set<ZSetOperations.TypedTuple<E>> diffWithScores(RedisZSet<?> set)
RedisZSet
RedisZSet
.diffWithScores
in interface RedisZSet<E>
set
- must not be null.Set
containing the values that differ with their scores.public Set<ZSetOperations.TypedTuple<E>> diffWithScores(Collection<? extends RedisZSet<?>> sets)
RedisZSet
RedisZSet
s.diffWithScores
in interface RedisZSet<E>
sets
- must not be null.Set
containing the values that differ with their scores.public RedisZSet<E> diffAndStore(RedisZSet<?> set, String destKey)
RedisZSet
RedisZSet
by diffing this sorted set and RedisZSet
and store result in destination
destKey
.diffAndStore
in interface RedisZSet<E>
set
- must not be null.destKey
- must not be null.RedisZSet
pointing at destKey
.public RedisZSet<E> diffAndStore(Collection<? extends RedisZSet<?>> sets, String destKey)
RedisZSet
RedisZSet
by diffing this sorted set and the collection RedisZSet
and store result in
destination destKey
.diffAndStore
in interface RedisZSet<E>
sets
- must not be null.destKey
- must not be null.RedisZSet
pointing at destKey
.public Set<E> intersect(RedisZSet<?> set)
RedisZSet
RedisZSet
.public Set<E> intersect(Collection<? extends RedisZSet<?>> sets)
RedisZSet
RedisZSet
s.public Set<ZSetOperations.TypedTuple<E>> intersectWithScores(RedisZSet<?> set)
RedisZSet
RedisZSet
.intersectWithScores
in interface RedisZSet<E>
set
- must not be null.Set
containing the intersecting values with their scores.public Set<ZSetOperations.TypedTuple<E>> intersectWithScores(Collection<? extends RedisZSet<?>> sets)
RedisZSet
RedisZSet
s.intersectWithScores
in interface RedisZSet<E>
sets
- must not be null.Set
containing the intersecting values with their scores.public RedisZSet<E> intersectAndStore(RedisZSet<?> set, String destKey)
RedisZSet
RedisZSet
by intersecting this sorted set and RedisZSet
and store result in
destination destKey
.intersectAndStore
in interface RedisZSet<E>
set
- must not be null.destKey
- must not be null.RedisZSet
pointing at destKey
public RedisZSet<E> intersectAndStore(Collection<? extends RedisZSet<?>> sets, String destKey)
RedisZSet
RedisZSet
by intersecting this sorted set and the collection RedisZSet
and store
result in destination destKey
.intersectAndStore
in interface RedisZSet<E>
sets
- must not be null.destKey
- must not be null.RedisZSet
pointing at destKey
public Set<E> union(RedisZSet<?> set)
RedisZSet
RedisZSet
.public Set<E> union(Collection<? extends RedisZSet<?>> sets)
RedisZSet
RedisZSet
s.public Set<ZSetOperations.TypedTuple<E>> unionWithScores(RedisZSet<?> set)
RedisZSet
RedisZSet
.unionWithScores
in interface RedisZSet<E>
set
- must not be null.Set
containing the combined values with their scores.public Set<ZSetOperations.TypedTuple<E>> unionWithScores(Collection<? extends RedisZSet<?>> sets)
RedisZSet
RedisZSet
s.unionWithScores
in interface RedisZSet<E>
sets
- must not be null.Set
containing the combined values with their scores.public RedisZSet<E> unionAndStore(RedisZSet<?> set, String destKey)
RedisZSet
RedisZSet
by union this sorted set and RedisZSet
and store result in destination
destKey
.unionAndStore
in interface RedisZSet<E>
set
- must not be null.destKey
- must not be null.RedisZSet
pointing at destKey
public RedisZSet<E> unionAndStore(Collection<? extends RedisZSet<?>> sets, String destKey)
RedisZSet
RedisZSet
by union this sorted set and the collection RedisZSet
and store result in
destination destKey
.unionAndStore
in interface RedisZSet<E>
sets
- must not be null.destKey
- must not be null.RedisZSet
pointing at destKey
public E randomValue()
RedisZSet
randomValue
in interface RedisZSet<E>
public Set<E> range(long start, long end)
RedisZSet
start
and end
from sorted set.public Set<E> reverseRange(long start, long end)
RedisZSet
start
to end
from sorted set ordered from high to low.reverseRange
in interface RedisZSet<E>
public Set<E> rangeByLex(RedisZSetCommands.Range range, RedisZSetCommands.Limit limit)
RedisZSet
RedisZSetCommands.Limit.getCount()
, starting at
RedisZSetCommands.Limit.getOffset()
with lexicographical ordering having a value between RedisZSetCommands.Range.getMin()
and
RedisZSetCommands.Range.getMax()
.rangeByLex
in interface RedisZSet<E>
range
- must not be null.limit
- can be null.BoundZSetOperations#rangeByLex(Range, Limit)
public Set<E> reverseRangeByLex(RedisZSetCommands.Range range, RedisZSetCommands.Limit limit)
RedisZSet
RedisZSetCommands.Limit.getCount()
, starting at
RedisZSetCommands.Limit.getOffset()
with reverse lexicographical ordering having a value between RedisZSetCommands.Range.getMin()
and
RedisZSetCommands.Range.getMax()
.reverseRangeByLex
in interface RedisZSet<E>
range
- must not be null.limit
- can be null.BoundZSetOperations#reverseRangeByLex(Range, Limit)
public Set<E> rangeByScore(double min, double max)
RedisZSet
min
and max
from sorted set.rangeByScore
in interface RedisZSet<E>
public Set<E> reverseRangeByScore(double min, double max)
RedisZSet
min
and max
from sorted set ordered from high to low.reverseRangeByScore
in interface RedisZSet<E>
public Set<ZSetOperations.TypedTuple<E>> rangeByScoreWithScores(double min, double max)
RedisZSet
RedisZSetCommands.Tuple
s where score is between min
and max
from sorted set.rangeByScoreWithScores
in interface RedisZSet<E>
public Set<ZSetOperations.TypedTuple<E>> rangeWithScores(long start, long end)
RedisZSet
RedisZSetCommands.Tuple
s between start
and end
from sorted set.rangeWithScores
in interface RedisZSet<E>
public Set<ZSetOperations.TypedTuple<E>> reverseRangeByScoreWithScores(double min, double max)
RedisZSet
RedisZSetCommands.Tuple
s where score is between min
and max
from sorted set
ordered from high to low.reverseRangeByScoreWithScores
in interface RedisZSet<E>
public Set<ZSetOperations.TypedTuple<E>> reverseRangeWithScores(long start, long end)
RedisZSet
RedisZSetCommands.Tuple
s in range from start
to end
from sorted set ordered from
high to low.reverseRangeWithScores
in interface RedisZSet<E>
public RedisZSet<E> remove(long start, long end)
RedisZSet
start
and end
from sorted set.public Set<E> removeByLex(RedisZSetCommands.Range range)
RedisZSet
removeByLex
in interface RedisZSet<E>
range
- must not be null.this
set.public RedisZSet<E> removeByScore(double min, double max)
RedisZSet
min
and max
from sorted set with the bound key.removeByScore
in interface RedisZSet<E>
this
set.public boolean add(E e)
RedisZSet
add(e, getDefaultScore())
. The score value
is implementation specific. public boolean add(E e, double score)
RedisZSet
public boolean addIfAbsent(E e, double score)
RedisZSet
addIfAbsent
in interface RedisZSet<E>
e
- element to addscore
- element scorepublic void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
clear
in class AbstractCollection<E>
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in interface Set<E>
contains
in class AbstractCollection<E>
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface Set<E>
remove
in class AbstractCollection<E>
public int size()
size
in interface Collection<E>
size
in interface Set<E>
size
in class AbstractCollection<E>
public Double getDefaultScore()
RedisZSet
getDefaultScore
in interface RedisZSet<E>
public E first()
RedisZSet
public E popFirst()
RedisZSet
public E popFirst(long timeout, TimeUnit unit)
RedisZSet
timeout
reached.public E last()
RedisZSet
public E popLast()
RedisZSet
public E popLast(long timeout, TimeUnit unit)
RedisZSet
timeout
reached.public Long rank(Object o)
RedisZSet
public Long reverseRank(Object o)
RedisZSet
reverseRank
in interface RedisZSet<E>
o
- objectpublic Long lexCount(RedisZSetCommands.Range range)
RedisZSet
Range#min
and Range#max
applying
lexicographical ordering.lexCount
in interface RedisZSet<E>
range
- must not be null.public Double score(Object o)
RedisZSet
public DataType getType()
BoundKeyOperations
getType
in interface BoundKeyOperations<String>
public Cursor<ZSetOperations.TypedTuple<E>> scan(ScanOptions options)
options
- Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.