Interface RedisList<E>

Type Parameters:
E - the type of elements in this collection.
All Superinterfaces:
BlockingDeque<E>, BlockingQueue<E>, BoundKeyOperations<String>, Collection<E>, Deque<E>, Iterable<E>, List<E>, Queue<E>, RedisCollection<E>, RedisStore
All Known Implementing Classes:
DefaultRedisList

public interface RedisList<E> extends RedisCollection<E>, List<E>, BlockingDeque<E>
Redis extension for the List contract. Supports List, Queue and Deque contracts as well as their equivalent blocking siblings BlockingDeque and BlockingDeque.
Author:
Costin Leau, Mark Paluch, John Blum
  • Method Details

    • create

      static <E> RedisList<E> create(String key, RedisOperations<String,E> operations)
      Constructs a new, uncapped RedisList instance.
      Parameters:
      key - Redis key of this list.
      operations - RedisOperations for the value type of this list.
      Since:
      2.6
    • create

      static <E> RedisList<E> create(String key, RedisOperations<String,E> operations, int maxSize)
      Factory method used to construct a new RedisList from a Redis list reference by the given key.
      Parameters:
      key - Redis key of this list.
      operations - RedisOperations for the value type of this list.
      maxSize - Integer used to constrain the size of the list.
      Since:
      2.6
    • create

      static <E> RedisList<E> create(BoundListOperations<String,E> boundOps)
      Constructs a new, uncapped DefaultRedisList instance.
      Parameters:
      boundOps - BoundListOperations for the value type of this list.
      Since:
      2.6
    • create

      static <E> RedisList<E> create(BoundListOperations<String,E> boundOps, int maxSize)
      Constructs a new DefaultRedisList.
      Parameters:
      boundOps - BoundListOperations for the value type of this list.
      maxSize - Integer constraining the size of the list.
      Since:
      2.6
    • moveFirstTo

      @Nullable 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.
      Parameters:
      destination - must not be null.
      destinationPosition - must not be null.
      Returns:
      Since:
      2.6
      See Also:
    • moveFirstTo

      @Nullable 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.

      Blocks connection until element available or timeout reached.

      Parameters:
      destination - must not be null.
      destinationPosition - must not be null.
      timeout -
      unit - must not be null.
      Returns:
      Since:
      2.6
      See Also:
    • moveFirstTo

      @Nullable default E moveFirstTo(RedisList<E> destination, RedisListCommands.Direction destinationPosition, Duration timeout)
      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.

      Blocks connection until element available or timeout reached.

      Parameters:
      destination - must not be null.
      destinationPosition - must not be null.
      timeout - must not be null or negative.
      Returns:
      Since:
      2.6
      See Also:
    • moveLastTo

      @Nullable 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.
      Parameters:
      destination - must not be null.
      destinationPosition - must not be null.
      Returns:
      Since:
      2.6
      See Also:
    • moveLastTo

      @Nullable 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.

      Blocks connection until element available or timeout reached.

      Parameters:
      destination - must not be null.
      destinationPosition - must not be null.
      timeout -
      unit - must not be null.
      Returns:
      Since:
      2.6
      See Also:
    • moveLastTo

      @Nullable default E moveLastTo(RedisList<E> destination, RedisListCommands.Direction destinationPosition, Duration timeout)
      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.

      Blocks connection until element available or timeout reached.

      Parameters:
      destination - must not be null.
      destinationPosition - must not be null.
      timeout - must not be null or negative.
      Returns:
      Since:
      2.6
      See Also:
    • range

      List<E> range(long start, long end)
      Get elements between start and end from list at the bound key.
      Parameters:
      start -
      end -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • trim

      RedisList<E> trim(int start, int end)
      Trim list at the bound key to elements between start and end.
      Parameters:
      start -
      end -
      See Also:
    • trim

      RedisList<E> trim(long start, long end)
      Trim list at the bound key to elements between start and end.
      Parameters:
      start -
      end -
      Since:
      2.6
      See Also:
    • addFirst

      default void addFirst(E element)

      This method is forward-compatible with Java 21 SequencedCollections.

      Specified by:
      addFirst in interface BlockingDeque<E>
      Specified by:
      addFirst in interface Deque<E>
      Parameters:
      element - element to be added to the head of the collection.
    • addLast

      default void addLast(E element)

      This method is forward-compatible with Java 21 SequencedCollections.

      Specified by:
      addLast in interface BlockingDeque<E>
      Specified by:
      addLast in interface Deque<E>
      Parameters:
      element - element to be added to be added the end of the collection.
    • getFirst

      @Nullable default E getFirst()

      This method is forward-compatible with Java 21 SequencedCollections.

      Specified by:
      getFirst in interface Deque<E>
      Returns:
      the head of this Deque.
    • getLast

      @Nullable default E getLast()

      This method is forward-compatible with Java 21 SequencedCollections.

      Specified by:
      getLast in interface Deque<E>
      Returns:
      the tail of this Deque.
    • removeFirst

      @Nullable default E removeFirst()

      This method is forward-compatible with Java 21 SequencedCollections.

      Specified by:
      removeFirst in interface Deque<E>
      Returns:
      the head of this Deque.
    • removeLast

      @Nullable default E removeLast()

      This method is forward-compatible with Java 21 SequencedCollections.

      Specified by:
      removeLast in interface Deque<E>
      Returns:
      the tail of this Deque.
    • reversed

      default RedisList<E> reversed()
      Returns a reverse-ordered view of this collection.

      The encounter order of elements returned by the view is the inverse of the encounter order of the elements stored in this collection. The reverse ordering affects all order-sensitive operations, including any operations on further views of the returned view. If the collection implementation permits modifications to this view, the modifications "write-through" to the underlying collection. Changes to the underlying collection might or might not be visible in this reversed view, depending upon the implementation.

      This method is forward-compatible with Java 21 SequencedCollections.

      Returns:
      a reverse-ordered view of this collection.