Interface ListOperations<K,V>


public interface ListOperations<K,V>
Redis list specific operations.
Author:
Costin Leau, David Liu, Thomas Darimont, Christoph Strobl, Mark Paluch, dengliming
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Value object representing the where from part for the LMOVE command.
    static class 
    Value object representing the where to from part for the LMOVE command.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    index(K key, long index)
    Get element at index form list at key.
    indexOf(K key, V value)
    Returns the index of the first occurrence of the specified value in the list at at key.
    lastIndexOf(K key, V value)
    Returns the index of the last occurrence of the specified value in the list at at key.
    leftPop(K key)
    Removes and returns first element in list stored at key.
    leftPop(K key, long count)
    Removes and returns first elements in list stored at key.
    leftPop(K key, long timeout, TimeUnit unit)
    Removes and returns first element from lists stored at key .
    default V
    leftPop(K key, Duration timeout)
    Removes and returns first element from lists stored at key .
    leftPush(K key, V value)
    Prepend value to key.
    leftPush(K key, V pivot, V value)
    Insert value to key before pivot.
    leftPushAll(K key, Collection<V> values)
    Prepend values to key.
    leftPushAll(K key, V... values)
    Prepend values to key.
    leftPushIfPresent(K key, V value)
    Prepend values to key only if the list exists.
    move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to)
    Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.
    move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to, long timeout, TimeUnit unit)
    Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.
    default V
    move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to, Duration timeout)
    Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.
    default V
    Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.
    default V
    Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.
    range(K key, long start, long end)
    Get elements between begin and end from list at key.
    remove(K key, long count, Object value)
    Removes the first count occurrences of value from the list stored at key.
    rightPop(K key)
    Removes and returns last element in list stored at key.
    rightPop(K key, long count)
    Removes and returns last elements in list stored at key.
    rightPop(K key, long timeout, TimeUnit unit)
    Removes and returns last element from lists stored at key.
    default V
    rightPop(K key, Duration timeout)
    Removes and returns last element from lists stored at key.
    rightPopAndLeftPush(K sourceKey, K destinationKey)
    Remove the last element from list at sourceKey, append it to destinationKey and return its value.
    rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit)
    Remove the last element from list at sourceKey, append it to destinationKey and return its value.
    Blocks connection until element available or timeout reached.
    default V
    rightPopAndLeftPush(K sourceKey, K destinationKey, Duration timeout)
    Remove the last element from list at sourceKey, append it to destinationKey and return its value.
    Blocks connection until element available or timeout reached.
    rightPush(K key, V value)
    Append value to key.
    rightPush(K key, V pivot, V value)
    Insert value to key after pivot.
    rightPushAll(K key, Collection<V> values)
    Append values to key.
    rightPushAll(K key, V... values)
    Append values to key.
    rightPushIfPresent(K key, V value)
    Append values to key only if the list exists.
    void
    set(K key, long index, V value)
    Set the value list element at index.
    size(K key)
    Get the size of list stored at key.
    void
    trim(K key, long start, long end)
    Trim list at key to elements between start and end.
  • Method Details

    • range

      @Nullable List<V> range(K key, long start, long end)
      Get elements between begin and end from list at key.
      Parameters:
      key - must not be null.
      start -
      end -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • trim

      void trim(K key, long start, long end)
      Trim list at key to elements between start and end.
      Parameters:
      key - must not be null.
      start -
      end -
      See Also:
    • size

      @Nullable Long size(K key)
      Get the size of list stored at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • leftPush

      @Nullable Long leftPush(K key, V value)
      Prepend value to key.
      Parameters:
      key - must not be null.
      value -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • leftPushAll

      @Nullable Long leftPushAll(K key, V... values)
      Prepend values to key.
      Parameters:
      key - must not be null.
      values -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • leftPushAll

      @Nullable Long leftPushAll(K key, Collection<V> values)
      Prepend values to key.
      Parameters:
      key - must not be null.
      values - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      1.5
      See Also:
    • leftPushIfPresent

      @Nullable Long leftPushIfPresent(K key, V value)
      Prepend values to key only if the list exists.
      Parameters:
      key - must not be null.
      value -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • leftPush

      @Nullable Long leftPush(K key, V pivot, V value)
      Insert value to key before pivot.
      Parameters:
      key - must not be null.
      pivot - must not be null.
      value -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • rightPush

      @Nullable Long rightPush(K key, V value)
      Append value to key.
      Parameters:
      key - must not be null.
      value -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • rightPushAll

      @Nullable Long rightPushAll(K key, V... values)
      Append values to key.
      Parameters:
      key - must not be null.
      values -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • rightPushAll

      @Nullable Long rightPushAll(K key, Collection<V> values)
      Append values to key.
      Parameters:
      key - must not be null.
      values -
      Returns:
      null when used in pipeline / transaction.
      Since:
      1.5
      See Also:
    • rightPushIfPresent

      @Nullable Long rightPushIfPresent(K key, V value)
      Append values to key only if the list exists.
      Parameters:
      key - must not be null.
      value -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • rightPush

      @Nullable Long rightPush(K key, V pivot, V value)
      Insert value to key after pivot.
      Parameters:
      key - must not be null.
      pivot - must not be null.
      value -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • move

      Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.
      Parameters:
      from - must not be null.
      to - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • move

      @Nullable V move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to)
      Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.
      Parameters:
      sourceKey - must not be null.
      from - must not be null.
      destinationKey - must not be null.
      to - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • move

      @Nullable default V move(ListOperations.MoveFrom<K> from, ListOperations.MoveTo<K> to, Duration timeout)
      Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.

      Blocks connection until element available or timeout reached.

      Parameters:
      from - must not be null.
      to - must not be null.
      timeout - must not be null or negative.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • move

      @Nullable default V move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to, Duration timeout)
      Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.

      Blocks connection until element available or timeout reached.

      Parameters:
      sourceKey - must not be null.
      from - must not be null.
      destinationKey - must not be null.
      to - must not be null.
      timeout - must not be null or negative.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • move

      @Nullable V move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to, long timeout, TimeUnit unit)
      Atomically returns and removes the first/last element (head/tail depending on the from argument) of the list stored at sourceKey, and pushes the element at the first/last element (head/tail depending on the to argument) of the list stored at destinationKey.

      Blocks connection until element available or timeout reached.

      Parameters:
      sourceKey - must not be null.
      from - must not be null.
      destinationKey - must not be null.
      to - must not be null.
      timeout -
      unit -
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • set

      void set(K key, long index, V value)
      Set the value list element at index.
      Parameters:
      key - must not be null.
      index -
      value -
      See Also:
    • remove

      @Nullable Long remove(K key, long count, Object value)
      Removes the first count occurrences of value from the list stored at key.
      Parameters:
      key - must not be null.
      count -
      value -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • index

      @Nullable V index(K key, long index)
      Get element at index form list at key.
      Parameters:
      key - must not be null.
      index -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • indexOf

      @Nullable Long indexOf(K key, V value)
      Returns the index of the first occurrence of the specified value in the list at at key.
      Requires Redis 6.0.6 or newer.
      Parameters:
      key - must not be null.
      value - must not be null.
      Returns:
      null when used in pipeline / transaction or when not contained in list.
      Since:
      2.4
      See Also:
    • lastIndexOf

      @Nullable Long lastIndexOf(K key, V value)
      Returns the index of the last occurrence of the specified value in the list at at key.
      Requires Redis 6.0.6 or newer.
      Parameters:
      key - must not be null.
      value - must not be null.
      Returns:
      null when used in pipeline / transaction or when not contained in list.
      Since:
      2.4
      See Also:
    • leftPop

      @Nullable V leftPop(K key)
      Removes and returns first element in list stored at key.
      Parameters:
      key - must not be null.
      Returns:
      can be null.
      See Also:
    • leftPop

      @Nullable List<V> leftPop(K key, long count)
      Removes and returns first elements in list stored at key.
      Parameters:
      key - must not be null.
      count -
      Returns:
      can be null.
      Since:
      2.6
      See Also:
    • leftPop

      @Nullable V leftPop(K key, long timeout, TimeUnit unit)
      Removes and returns first element from lists stored at key .
      Blocks connection until element available or timeout reached.
      Parameters:
      key - must not be null.
      timeout -
      unit - must not be null.
      Returns:
      can be null.
      See Also:
    • leftPop

      @Nullable default V leftPop(K key, Duration timeout)
      Removes and returns first element from lists stored at key .
      Blocks connection until element available or timeout reached.
      Parameters:
      key - must not be null.
      timeout - must not be null.
      Returns:
      can be null.
      Throws:
      IllegalArgumentException - if the timeout is null or negative.
      Since:
      2.3
      See Also:
    • rightPop

      @Nullable V rightPop(K key)
      Removes and returns last element in list stored at key.
      Parameters:
      key - must not be null.
      Returns:
      can be null.
      See Also:
    • rightPop

      @Nullable List<V> rightPop(K key, long count)
      Removes and returns last elements in list stored at key.
      Parameters:
      key - must not be null.
      count -
      Returns:
      can be null.
      Since:
      2.6
      See Also:
    • rightPop

      @Nullable V rightPop(K key, long timeout, TimeUnit unit)
      Removes and returns last element from lists stored at key.
      Blocks connection until element available or timeout reached.
      Parameters:
      key - must not be null.
      timeout -
      unit - must not be null.
      Returns:
      can be null.
      See Also:
    • rightPop

      @Nullable default V rightPop(K key, Duration timeout)
      Removes and returns last element from lists stored at key.
      Blocks connection until element available or timeout reached.
      Parameters:
      key - must not be null.
      timeout - must not be null.
      Returns:
      can be null.
      Since:
      2.3
      See Also:
    • rightPopAndLeftPush

      @Nullable V rightPopAndLeftPush(K sourceKey, K destinationKey)
      Remove the last element from list at sourceKey, append it to destinationKey and return its value.
      Parameters:
      sourceKey - must not be null.
      destinationKey - must not be null.
      Returns:
      can be null.
      See Also:
    • rightPopAndLeftPush

      @Nullable V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit)
      Remove the last element from list at sourceKey, append it to destinationKey and return its value.
      Blocks connection until element available or timeout reached.
      Parameters:
      sourceKey - must not be null.
      destinationKey - must not be null.
      timeout -
      unit - must not be null.
      Returns:
      can be null.
      See Also:
    • rightPopAndLeftPush

      @Nullable default V rightPopAndLeftPush(K sourceKey, K destinationKey, Duration timeout)
      Remove the last element from list at sourceKey, append it to destinationKey and return its value.
      Blocks connection until element available or timeout reached.
      Parameters:
      sourceKey - must not be null.
      destinationKey - must not be null.
      timeout - must not be null.
      Returns:
      can be null.
      Throws:
      IllegalArgumentException - if the timeout is null or negative.
      Since:
      2.3
      See Also:
    • getOperations

      RedisOperations<K,V> getOperations()