Spring Data Key-Value

org.springframework.data.keyvalue.redis.support.collections
Class DefaultRedisList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by org.springframework.data.keyvalue.redis.support.collections.AbstractRedisCollection<E>
          extended by org.springframework.data.keyvalue.redis.support.collections.DefaultRedisList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, BlockingDeque<E>, BlockingQueue<E>, Deque<E>, List<E>, Queue<E>, KeyBound<String>, RedisCollection<E>, RedisList<E>, RedisStore

public class DefaultRedisList<E>
extends AbstractRedisCollection<E>
implements RedisList<E>

Default implementation for RedisList. Suitable for not just lists, but also queues (FIFO ordering) or stacks (LIFO ordering) and deques (or double ended queues). Allows the maximum size (or the cap) to be specified to prevent the list from over growing. Note that all write operations will execute immediately, whether a cap is specified or not - the list will always accept new items (trimming the tail after each insert in case of capped collections).

Author:
Costin Leau

Field Summary
 
Fields inherited from class org.springframework.data.keyvalue.redis.support.collections.AbstractRedisCollection
ENCODING
 
Constructor Summary
DefaultRedisList(BoundListOperations<String,E> boundOps)
          Constructs a new, uncapped DefaultRedisList instance.
DefaultRedisList(BoundListOperations<String,E> boundOps, int maxSize)
          Constructs a new DefaultRedisList instance.
DefaultRedisList(String key, RedisOperations<String,E> operations)
          Constructs a new, uncapped DefaultRedisList instance.
 
Method Summary
 boolean add(E value)
           
 void add(int index, E element)
           
 boolean addAll(int index, Collection<? extends E> c)
           
 void addFirst(E e)
           
 void addLast(E e)
           
 void clear()
           
 Iterator<E> descendingIterator()
           
 int drainTo(Collection<? super E> c)
           
 int drainTo(Collection<? super E> c, int maxElements)
           
 E element()
           
 E get(int index)
           
 E getFirst()
           
 E getLast()
           
 int indexOf(Object o)
           
 Iterator<E> iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator<E> listIterator()
           
 ListIterator<E> listIterator(int index)
           
 boolean offer(E e)
           
 boolean offer(E e, long timeout, TimeUnit unit)
           
 boolean offerFirst(E e)
           
 boolean offerFirst(E e, long timeout, TimeUnit unit)
           
 boolean offerLast(E e)
           
 boolean offerLast(E e, long timeout, TimeUnit unit)
           
 E peek()
           
 E peekFirst()
           
 E peekLast()
           
 E poll()
           
 E poll(long timeout, TimeUnit unit)
           
 E pollFirst()
           
 E pollFirst(long timeout, TimeUnit unit)
           
 E pollLast()
           
 E pollLast(long timeout, TimeUnit unit)
           
 E pop()
           
 void push(E e)
           
 void put(E e)
           
 void putFirst(E e)
           
 void putLast(E e)
           
 List<E> range(long start, long end)
           
 int remainingCapacity()
           
 E remove()
           
 E remove(int index)
           
 boolean remove(Object o)
           
 E removeFirst()
           
 boolean removeFirstOccurrence(Object o)
           
 E removeLast()
           
 boolean removeLastOccurrence(Object o)
           
 E set(int index, E e)
           
 void setMaxSize(int maxSize)
          Sets the maximum size of the (capped) list.
 int size()
           
 List<E> subList(int fromIndex, int toIndex)
           
 E take()
           
 E takeFirst()
           
 E takeLast()
           
 RedisList<E> trim(int start, int end)
           
 
Methods inherited from class org.springframework.data.keyvalue.redis.support.collections.AbstractRedisCollection
addAll, containsAll, equals, getKey, getOperations, hashCode, removeAll, retainAll, toString
 
Methods inherited from class java.util.AbstractCollection
contains, isEmpty, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
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.List
addAll, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 
Methods inherited from interface java.util.concurrent.BlockingDeque
contains
 

Constructor Detail

DefaultRedisList

public DefaultRedisList(String key,
                        RedisOperations<String,E> operations)
Constructs a new, uncapped DefaultRedisList instance.

Parameters:
key -
operations -

DefaultRedisList

public DefaultRedisList(BoundListOperations<String,E> boundOps)
Constructs a new, uncapped DefaultRedisList instance.

Parameters:
boundOps -

DefaultRedisList

public DefaultRedisList(BoundListOperations<String,E> boundOps,
                        int maxSize)
Constructs a new DefaultRedisList instance.

Parameters:
boundOps -
maxSize -
Method Detail

setMaxSize

public void setMaxSize(int maxSize)
Sets the maximum size of the (capped) list. A value of 0 means unlimited.

Parameters:
maxSize - list maximum size

range

public List<E> range(long start,
                     long end)
Specified by:
range in interface RedisList<E>

trim

public RedisList<E> trim(int start,
                         int end)
Specified by:
trim in interface RedisList<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface BlockingDeque<E>
Specified by:
iterator in interface Deque<E>
Specified by:
iterator in interface List<E>
Specified by:
iterator in class AbstractCollection<E>

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface BlockingDeque<E>
Specified by:
size in interface Deque<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>

add

public boolean add(E value)
Specified by:
add in interface Collection<E>
Specified by:
add in interface BlockingDeque<E>
Specified by:
add in interface BlockingQueue<E>
Specified by:
add in interface Deque<E>
Specified by:
add in interface List<E>
Specified by:
add in interface Queue<E>
Specified by:
add in class AbstractRedisCollection<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Specified by:
clear in class AbstractRedisCollection<E>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface BlockingDeque<E>
Specified by:
remove in interface BlockingQueue<E>
Specified by:
remove in interface Deque<E>
Specified by:
remove in interface List<E>
Specified by:
remove in class AbstractRedisCollection<E>

add

public void add(int index,
                E element)
Specified by:
add in interface List<E>

addAll

public boolean addAll(int index,
                      Collection<? extends E> c)
Specified by:
addAll in interface List<E>

get

public E get(int index)
Specified by:
get in interface List<E>

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List<E>

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List<E>

listIterator

public ListIterator<E> listIterator()
Specified by:
listIterator in interface List<E>

listIterator

public ListIterator<E> listIterator(int index)
Specified by:
listIterator in interface List<E>

remove

public E remove(int index)
Specified by:
remove in interface List<E>

set

public E set(int index,
             E e)
Specified by:
set in interface List<E>

subList

public List<E> subList(int fromIndex,
                       int toIndex)
Specified by:
subList in interface List<E>

element

public E element()
Specified by:
element in interface BlockingDeque<E>
Specified by:
element in interface Deque<E>
Specified by:
element in interface Queue<E>

offer

public boolean offer(E e)
Specified by:
offer in interface BlockingDeque<E>
Specified by:
offer in interface BlockingQueue<E>
Specified by:
offer in interface Deque<E>
Specified by:
offer in interface Queue<E>

peek

public E peek()
Specified by:
peek in interface BlockingDeque<E>
Specified by:
peek in interface Deque<E>
Specified by:
peek in interface Queue<E>

poll

public E poll()
Specified by:
poll in interface BlockingDeque<E>
Specified by:
poll in interface Deque<E>
Specified by:
poll in interface Queue<E>

remove

public E remove()
Specified by:
remove in interface BlockingDeque<E>
Specified by:
remove in interface Deque<E>
Specified by:
remove in interface Queue<E>

addFirst

public void addFirst(E e)
Specified by:
addFirst in interface BlockingDeque<E>
Specified by:
addFirst in interface Deque<E>

addLast

public void addLast(E e)
Specified by:
addLast in interface BlockingDeque<E>
Specified by:
addLast in interface Deque<E>

descendingIterator

public Iterator<E> descendingIterator()
Specified by:
descendingIterator in interface Deque<E>

getFirst

public E getFirst()
Specified by:
getFirst in interface Deque<E>

getLast

public E getLast()
Specified by:
getLast in interface Deque<E>

offerFirst

public boolean offerFirst(E e)
Specified by:
offerFirst in interface BlockingDeque<E>
Specified by:
offerFirst in interface Deque<E>

offerLast

public boolean offerLast(E e)
Specified by:
offerLast in interface BlockingDeque<E>
Specified by:
offerLast in interface Deque<E>

peekFirst

public E peekFirst()
Specified by:
peekFirst in interface Deque<E>

peekLast

public E peekLast()
Specified by:
peekLast in interface Deque<E>

pollFirst

public E pollFirst()
Specified by:
pollFirst in interface Deque<E>

pollLast

public E pollLast()
Specified by:
pollLast in interface Deque<E>

pop

public E pop()
Specified by:
pop in interface Deque<E>

push

public void push(E e)
Specified by:
push in interface BlockingDeque<E>
Specified by:
push in interface Deque<E>

removeFirst

public E removeFirst()
Specified by:
removeFirst in interface Deque<E>

removeFirstOccurrence

public boolean removeFirstOccurrence(Object o)
Specified by:
removeFirstOccurrence in interface BlockingDeque<E>
Specified by:
removeFirstOccurrence in interface Deque<E>

removeLast

public E removeLast()
Specified by:
removeLast in interface Deque<E>

removeLastOccurrence

public boolean removeLastOccurrence(Object o)
Specified by:
removeLastOccurrence in interface BlockingDeque<E>
Specified by:
removeLastOccurrence in interface Deque<E>

drainTo

public int drainTo(Collection<? super E> c,
                   int maxElements)
Specified by:
drainTo in interface BlockingQueue<E>

drainTo

public int drainTo(Collection<? super E> c)
Specified by:
drainTo in interface BlockingQueue<E>

offer

public boolean offer(E e,
                     long timeout,
                     TimeUnit unit)
              throws InterruptedException
Specified by:
offer in interface BlockingDeque<E>
Specified by:
offer in interface BlockingQueue<E>
Throws:
InterruptedException

poll

public E poll(long timeout,
              TimeUnit unit)
       throws InterruptedException
Specified by:
poll in interface BlockingDeque<E>
Specified by:
poll in interface BlockingQueue<E>
Throws:
InterruptedException

put

public void put(E e)
         throws InterruptedException
Specified by:
put in interface BlockingDeque<E>
Specified by:
put in interface BlockingQueue<E>
Throws:
InterruptedException

remainingCapacity

public int remainingCapacity()
Specified by:
remainingCapacity in interface BlockingQueue<E>

take

public E take()
       throws InterruptedException
Specified by:
take in interface BlockingDeque<E>
Specified by:
take in interface BlockingQueue<E>
Throws:
InterruptedException

offerFirst

public boolean offerFirst(E e,
                          long timeout,
                          TimeUnit unit)
                   throws InterruptedException
Specified by:
offerFirst in interface BlockingDeque<E>
Throws:
InterruptedException

offerLast

public boolean offerLast(E e,
                         long timeout,
                         TimeUnit unit)
                  throws InterruptedException
Specified by:
offerLast in interface BlockingDeque<E>
Throws:
InterruptedException

pollFirst

public E pollFirst(long timeout,
                   TimeUnit unit)
            throws InterruptedException
Specified by:
pollFirst in interface BlockingDeque<E>
Throws:
InterruptedException

pollLast

public E pollLast(long timeout,
                  TimeUnit unit)
           throws InterruptedException
Specified by:
pollLast in interface BlockingDeque<E>
Throws:
InterruptedException

putFirst

public void putFirst(E e)
              throws InterruptedException
Specified by:
putFirst in interface BlockingDeque<E>
Throws:
InterruptedException

putLast

public void putLast(E e)
             throws InterruptedException
Specified by:
putLast in interface BlockingDeque<E>
Throws:
InterruptedException

takeFirst

public E takeFirst()
            throws InterruptedException
Specified by:
takeFirst in interface BlockingDeque<E>
Throws:
InterruptedException

takeLast

public E takeLast()
           throws InterruptedException
Specified by:
takeLast in interface BlockingDeque<E>
Throws:
InterruptedException

Spring Data Key-Value

Copyright © 2010-2011 SpringSource. All Rights Reserved.