org.springframework.data.redis.support.collections
Interface RedisZSet<E>

All Superinterfaces:
BoundKeyOperations<String>, Collection<E>, Iterable<E>, RedisCollection<E>, RedisStore, Set<E>
All Known Implementing Classes:
DefaultRedisZSet

public interface RedisZSet<E>
extends RedisCollection<E>, Set<E>

Redis ZSet (or sorted set (by weight)). Acts as a SortedSet based on the given priorities or weights associated with each item.

Since using a Comparator does not apply, a ZSet implements the SortedSet methods where applicable.


Method Summary
 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.
 E first()
          Returns the first (lowest) element currently in this sorted set.
 Double getDefaultScore()
          Returns the default score used by this set.
 RedisZSet<E> intersectAndStore(Collection<? extends RedisZSet<?>> sets, String destKey)
           
 RedisZSet<E> intersectAndStore(RedisZSet<?> set, String destKey)
           
 E last()
          Returns the last (highest) element currently in this sorted set.
 Set<E> range(long start, long end)
           
 Set<E> rangeByScore(double min, double max)
           
 Set<ZSetOperations.TypedTuple<E>> rangeByScoreWithScores(double min, double max)
           
 Set<ZSetOperations.TypedTuple<E>> rangeWithScores(long start, long end)
           
 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)
           
 RedisZSet<E> removeByScore(double min, double max)
           
 Set<E> reverseRange(long start, long end)
           
 Set<E> reverseRangeByScore(double min, double max)
           
 Set<ZSetOperations.TypedTuple<E>> reverseRangeByScoreWithScores(double min, double max)
           
 Set<ZSetOperations.TypedTuple<E>> reverseRangeWithScores(long start, long end)
           
 Long reverseRank(Object o)
          Returns the rank (position) of the given element in the set, in descending order.
 Double score(Object o)
          Returns the score of the given element.
 RedisZSet<E> unionAndStore(Collection<? extends RedisZSet<?>> sets, String destKey)
           
 RedisZSet<E> unionAndStore(RedisZSet<?> set, String destKey)
           
 
Methods inherited from interface org.springframework.data.redis.support.collections.RedisStore
getOperations
 
Methods inherited from interface org.springframework.data.redis.core.BoundKeyOperations
expire, expireAt, getExpire, getKey, getType, persist, rename
 
Methods inherited from interface java.util.Set
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

intersectAndStore

RedisZSet<E> intersectAndStore(RedisZSet<?> set,
                               String destKey)

intersectAndStore

RedisZSet<E> intersectAndStore(Collection<? extends RedisZSet<?>> sets,
                               String destKey)

unionAndStore

RedisZSet<E> unionAndStore(RedisZSet<?> set,
                           String destKey)

unionAndStore

RedisZSet<E> unionAndStore(Collection<? extends RedisZSet<?>> sets,
                           String destKey)

range

Set<E> range(long start,
             long end)

reverseRange

Set<E> reverseRange(long start,
                    long end)

rangeByScore

Set<E> rangeByScore(double min,
                    double max)

reverseRangeByScore

Set<E> reverseRangeByScore(double min,
                           double max)

rangeWithScores

Set<ZSetOperations.TypedTuple<E>> rangeWithScores(long start,
                                                  long end)

reverseRangeWithScores

Set<ZSetOperations.TypedTuple<E>> reverseRangeWithScores(long start,
                                                         long end)

rangeByScoreWithScores

Set<ZSetOperations.TypedTuple<E>> rangeByScoreWithScores(double min,
                                                         double max)

reverseRangeByScoreWithScores

Set<ZSetOperations.TypedTuple<E>> reverseRangeByScoreWithScores(double min,
                                                                double max)

remove

RedisZSet<E> remove(long start,
                    long end)

removeByScore

RedisZSet<E> removeByScore(double min,
                           double max)

add

boolean add(E e,
            double score)
Adds an element to the set with the given score, or updates the score if the element exists.

Parameters:
e - element to add
score - element score
Returns:
true if a new element was added, false otherwise (only the score has been updated)

add

boolean add(E e)
Adds an element to the set with a default score. Equivalent to add(e, getDefaultScore()). The score value is implementation specific.

Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>

score

Double score(Object o)
Returns the score of the given element. Returns null if the element is not contained by the set.

Parameters:
o - object
Returns:
the score associated with the given object

rank

Long rank(Object o)
Returns the rank (position) of the given element in the set, in ascending order. Returns null if the element is not contained by the set.

Parameters:
o - object
Returns:
rank of the given object

reverseRank

Long reverseRank(Object o)
Returns the rank (position) of the given element in the set, in descending order. Returns null if the element is not contained by the set.

Parameters:
o - object
Returns:
reverse rank of the given object

getDefaultScore

Double getDefaultScore()
Returns the default score used by this set.

Returns:
the default score used by the implementation.

first

E first()
Returns the first (lowest) element currently in this sorted set.

Returns:
the first (lowest) element currently in this sorted set.
Throws:
NoSuchElementException - sorted set is empty.

last

E last()
Returns the last (highest) element currently in this sorted set.

Returns:
the last (highest) element currently in this sorted set.
Throws:
NoSuchElementException - sorted set is empty.