public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements RedisList<E>
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).ENCODING| Constructor and Description |
|---|
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. |
DefaultRedisList(String key,
RedisOperations<String,E> operations,
int maxSize)
Constructs a new
DefaultRedisList instance. |
| Modifier and Type | Method and Description |
|---|---|
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() |
DataType |
getType()
Returns the associated Redis type.
|
int |
indexOf(Object o) |
Iterator<E> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
E |
moveFirstTo(RedisList<E> destination,
RedisListCommands.Direction destinationPosition)
Atomically returns and removes the first element of the list stored at the bound key, and pushes the element at the
first/last element (head/tail depending on the
destinationPosition argument) of the list stored
at destination. |
E |
moveFirstTo(RedisList<E> destination,
RedisListCommands.Direction destinationPosition,
long timeout,
TimeUnit unit)
Atomically returns and removes the first element of the list stored at the bound key, and pushes the element at the
first/last element (head/tail depending on the
destinationPosition argument) of the list stored
at destination. |
E |
moveLastTo(RedisList<E> destination,
RedisListCommands.Direction destinationPosition)
Atomically returns and removes the last element of the list stored at the bound key, and pushes the element at the
first/last element (head/tail depending on the
destinationPosition argument) of the list stored
at destination. |
E |
moveLastTo(RedisList<E> destination,
RedisListCommands.Direction destinationPosition,
long timeout,
TimeUnit unit)
Atomically returns and removes the last element of the list stored at the bound key, and pushes the element at the
first/last element (head/tail depending on the
destinationPosition argument) of the list stored
at destination. |
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)
Get elements between
start and end from list at the bound key. |
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)
Trim list at the bound key to elements between
start and end. |
RedisList<E> |
trim(long start,
long end)
Trim list at the bound key to elements between
start and end. |
addAll, checkResult, containsAll, equals, expire, expireAt, getExpire, getKey, getOperations, hashCode, persist, removeAll, rename, toStringcontains, isEmpty, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitcreate, create, create, create, moveFirstTo, moveLastTogetOperationsexpire, expire, expireAt, expireAt, getExpire, getKey, persist, renameaddAll, contains, containsAll, equals, hashCode, isEmpty, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArraycontainsparallelStream, removeIf, streampublic DefaultRedisList(String key, RedisOperations<String,E> operations)
DefaultRedisList instance.key - Redis key of this list.operations - RedisOperations for the value type of this list.public DefaultRedisList(String key, RedisOperations<String,E> operations, int maxSize)
DefaultRedisList instance.key - Redis key of this list.operations - RedisOperations for the value type of this list.maxSize - public DefaultRedisList(BoundListOperations<String,E> boundOps)
DefaultRedisList instance.boundOps - BoundListOperations for the value type of this list.public DefaultRedisList(BoundListOperations<String,E> boundOps, int maxSize)
DefaultRedisList instance.boundOps - BoundListOperations for the value type of this list.maxSize - public void setMaxSize(int maxSize)
maxSize - list maximum sizepublic E moveFirstTo(RedisList<E> destination, RedisListCommands.Direction destinationPosition)
RedisListdestinationPosition argument) of the list stored
at destination.moveFirstTo in interface RedisList<E>destination - must not be null.destinationPosition - must not be null.RedisListCommands.Direction.first(),
RedisListCommands.Direction.last()public E moveFirstTo(RedisList<E> destination, RedisListCommands.Direction destinationPosition, long timeout, TimeUnit unit)
RedisListdestinationPosition argument) of the list stored
at destination.
Blocks connection until element available or timeout reached.
moveFirstTo in interface RedisList<E>destination - must not be null.destinationPosition - must not be null.unit - must not be null.RedisListCommands.Direction.first(),
RedisListCommands.Direction.last()public E moveLastTo(RedisList<E> destination, RedisListCommands.Direction destinationPosition)
RedisListdestinationPosition argument) of the list stored
at destination.moveLastTo in interface RedisList<E>destination - must not be null.destinationPosition - must not be null.RedisListCommands.Direction.first(),
RedisListCommands.Direction.last()public E moveLastTo(RedisList<E> destination, RedisListCommands.Direction destinationPosition, long timeout, TimeUnit unit)
RedisListdestinationPosition argument) of the list stored
at destination.
Blocks connection until element available or timeout reached.
moveLastTo in interface RedisList<E>destination - must not be null.destinationPosition - must not be null.unit - must not be null.RedisListCommands.Direction.first(),
RedisListCommands.Direction.last()public List<E> range(long start, long end)
RedisListstart and end from list at the bound key.range in interface RedisList<E>public RedisList<E> trim(int start, int end)
RedisListstart and end.trim in interface RedisList<E>public RedisList<E> trim(long start, long end)
RedisListstart and end.trim in interface RedisList<E>public int size()
size in interface Collection<E>size in interface BlockingDeque<E>size in interface Deque<E>size in interface List<E>size in class AbstractCollection<E>public boolean add(E value)
add in interface Collection<E>add in interface BlockingDeque<E>add in interface BlockingQueue<E>add in interface Deque<E>add in interface List<E>add in interface Queue<E>add in class AbstractCollection<E>public void clear()
clear in interface Collection<E>clear in interface List<E>clear in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface BlockingDeque<E>remove in interface BlockingQueue<E>remove in interface Deque<E>remove in interface List<E>remove in class AbstractCollection<E>public boolean addAll(int index,
Collection<? extends E> c)
public int lastIndexOf(Object o)
lastIndexOf in interface List<E>public ListIterator<E> listIterator()
listIterator in interface List<E>public ListIterator<E> listIterator(int index)
listIterator in interface List<E>public E element()
public boolean offer(E e)
public E remove()
public void addFirst(E e)
public void addLast(E e)
public Iterator<E> descendingIterator()
descendingIterator in interface Deque<E>public boolean offerFirst(E e)
offerFirst in interface BlockingDeque<E>offerFirst in interface Deque<E>public boolean offerLast(E e)
public void push(E e)
public E removeFirst()
removeFirst in interface Deque<E>public boolean removeFirstOccurrence(Object o)
removeFirstOccurrence in interface BlockingDeque<E>removeFirstOccurrence in interface Deque<E>public E removeLast()
removeLast in interface Deque<E>public boolean removeLastOccurrence(Object o)
removeLastOccurrence in interface BlockingDeque<E>removeLastOccurrence in interface Deque<E>public int drainTo(Collection<? super E> c, int maxElements)
drainTo in interface BlockingQueue<E>public int drainTo(Collection<? super E> c)
drainTo in interface BlockingQueue<E>public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
offer in interface BlockingDeque<E>offer in interface BlockingQueue<E>InterruptedException@Nullable public E poll(long timeout, TimeUnit unit) throws InterruptedException
poll in interface BlockingDeque<E>poll in interface BlockingQueue<E>InterruptedExceptionpublic void put(E e) throws InterruptedException
put in interface BlockingDeque<E>put in interface BlockingQueue<E>InterruptedExceptionpublic int remainingCapacity()
remainingCapacity in interface BlockingQueue<E>@Nullable public E take() throws InterruptedException
take in interface BlockingDeque<E>take in interface BlockingQueue<E>InterruptedExceptionpublic boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException
offerFirst in interface BlockingDeque<E>InterruptedExceptionpublic boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException
offerLast in interface BlockingDeque<E>InterruptedException@Nullable public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException
pollFirst in interface BlockingDeque<E>InterruptedException@Nullable public E pollLast(long timeout, TimeUnit unit) throws InterruptedException
pollLast in interface BlockingDeque<E>InterruptedExceptionpublic void putFirst(E e) throws InterruptedException
putFirst in interface BlockingDeque<E>InterruptedExceptionpublic void putLast(E e) throws InterruptedException
putLast in interface BlockingDeque<E>InterruptedException@Nullable public E takeFirst() throws InterruptedException
takeFirst in interface BlockingDeque<E>InterruptedException@Nullable public E takeLast() throws InterruptedException
takeLast in interface BlockingDeque<E>InterruptedExceptionpublic DataType getType()
BoundKeyOperationsgetType in interface BoundKeyOperations<String>Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.