Spring Data Key-Value

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

All Superinterfaces:
Collection<E>, Iterable<E>, KeyBound<String>, 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.

Author:
Costin Leau

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(String destKey, Collection<? extends RedisZSet<?>> sets)
           
 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)
           
 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)
           
 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(String destKey, Collection<? extends RedisZSet<?>> sets)
           
 
Methods inherited from interface org.springframework.data.keyvalue.redis.support.collections.RedisStore
getOperations
 
Methods inherited from interface org.springframework.data.keyvalue.redis.core.KeyBound
getKey
 
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(String destKey,
                               Collection<? extends RedisZSet<?>> sets)

unionAndStore

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

range

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

reverseRange

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

rangeByScore

Set<E> rangeByScore(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.

Spring Data Key-Value

Copyright © 2010-2011 SpringSource. All Rights Reserved.