Interface ValueOperations<K,V>


public interface ValueOperations<K,V>
Redis operations for simple (or in Redis terminology 'string') values.
Author:
Costin Leau, Christoph Strobl, Mark Paluch, Jiahe Cai
  • Method Summary

    Modifier and Type
    Method
    Description
    append(K key, String value)
    Append a value to key.
    bitField(K key, BitFieldSubCommands subCommands)
    Get / Manipulate specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset stored at a given key.
    decrement(K key)
    Decrement an integer value stored as string value under key by one.
    decrement(K key, long delta)
    Decrement an integer value stored as string value under key by delta.
    get(Object key)
    Get the value of key.
    get(K key, long start, long end)
    Get a substring of value of key between begin and end.
    Return the value at key and delete the key.
    getAndExpire(K key, long timeout, TimeUnit unit)
    Return the value at key and expire the key by applying timeout.
    getAndExpire(K key, Duration timeout)
    Return the value at key and expire the key by applying timeout.
    Return the value at key and persist the key.
    getAndSet(K key, V value)
    Set value of key and return its old value.
    getBit(K key, long offset)
    Get the bit value at offset of value at key.
     
    increment(K key)
    Increment an integer value stored as string value under key by one.
    increment(K key, double delta)
    Increment a floating point number value stored as string value under key by delta.
    increment(K key, long delta)
    Increment an integer value stored as string value under key by delta.
    Get multiple keys.
    void
    multiSet(Map<? extends K,? extends V> map)
    Set multiple keys to multiple values using key-value pairs provided in tuple.
    multiSetIfAbsent(Map<? extends K,? extends V> map)
    Set multiple keys to multiple values using key-value pairs provided in tuple only if the provided key does not exist.
    void
    set(K key, V value)
    Set value for key.
    void
    set(K key, V value, long offset)
    Overwrite parts of key starting at the specified offset with given value.
    void
    set(K key, V value, long timeout, TimeUnit unit)
    Set the value and expiration timeout for key.
    default void
    set(K key, V value, Duration timeout)
    Set the value and expiration timeout for key.
    setBit(K key, long offset, boolean value)
    Sets the bit at offset in value stored at key.
    setIfAbsent(K key, V value)
    Set key to hold the string value if key is absent.
    setIfAbsent(K key, V value, long timeout, TimeUnit unit)
    Set key to hold the string value and expiration timeout if key is absent.
    default Boolean
    setIfAbsent(K key, V value, Duration timeout)
    Set key to hold the string value and expiration timeout if key is absent.
    setIfPresent(K key, V value)
    Set key to hold the string value if key is present.
    setIfPresent(K key, V value, long timeout, TimeUnit unit)
    Set key to hold the string value and expiration timeout if key is present.
    default Boolean
    setIfPresent(K key, V value, Duration timeout)
    Set key to hold the string value and expiration timeout if key is present.
    size(K key)
    Get the length of the value stored at key.
  • Method Details

    • set

      void set(K key, V value)
      Set value for key.
      Parameters:
      key - must not be null.
      value - must not be null.
      See Also:
    • set

      void set(K key, V value, long timeout, TimeUnit unit)
      Set the value and expiration timeout for key.
      Parameters:
      key - must not be null.
      value - must not be null.
      timeout - the key expiration timeout.
      unit - must not be null.
      See Also:
    • set

      default void set(K key, V value, Duration timeout)
      Set the value and expiration timeout for key.
      Parameters:
      key - must not be null.
      value - must not be null.
      timeout - must not be null.
      Throws:
      IllegalArgumentException - if either key, value or timeout is not present.
      Since:
      2.1
      See Also:
    • setIfAbsent

      @Nullable Boolean setIfAbsent(K key, V value)
      Set key to hold the string value if key is absent.
      Parameters:
      key - must not be null.
      value - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • setIfAbsent

      @Nullable Boolean setIfAbsent(K key, V value, long timeout, TimeUnit unit)
      Set key to hold the string value and expiration timeout if key is absent.
      Parameters:
      key - must not be null.
      value - must not be null.
      timeout - the key expiration timeout.
      unit - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.1
      See Also:
    • setIfAbsent

      @Nullable default Boolean setIfAbsent(K key, V value, Duration timeout)
      Set key to hold the string value and expiration timeout if key is absent.
      Parameters:
      key - must not be null.
      value - must not be null.
      timeout - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Throws:
      IllegalArgumentException - if either key, value or timeout is not present.
      Since:
      2.1
      See Also:
    • setIfPresent

      @Nullable Boolean setIfPresent(K key, V value)
      Set key to hold the string value if key is present.
      Parameters:
      key - must not be null.
      value - must not be null.
      Returns:
      command result indicating if the key has been set.
      Throws:
      IllegalArgumentException - if either key or value is not present.
      Since:
      2.1
      See Also:
    • setIfPresent

      @Nullable Boolean setIfPresent(K key, V value, long timeout, TimeUnit unit)
      Set key to hold the string value and expiration timeout if key is present.
      Parameters:
      key - must not be null.
      value - must not be null.
      timeout - the key expiration timeout.
      unit - must not be null.
      Returns:
      command result indicating if the key has been set.
      Throws:
      IllegalArgumentException - if either key, value or timeout is not present.
      Since:
      2.1
      See Also:
    • setIfPresent

      @Nullable default Boolean setIfPresent(K key, V value, Duration timeout)
      Set key to hold the string value and expiration timeout if key is present.
      Parameters:
      key - must not be null.
      value - must not be null.
      timeout - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Throws:
      IllegalArgumentException - if either key, value or timeout is not present.
      Since:
      2.1
      See Also:
    • multiSet

      void multiSet(Map<? extends K,? extends V> map)
      Set multiple keys to multiple values using key-value pairs provided in tuple.
      Parameters:
      map - must not be null.
      See Also:
    • multiSetIfAbsent

      @Nullable Boolean multiSetIfAbsent(Map<? extends K,? extends V> map)
      Set multiple keys to multiple values using key-value pairs provided in tuple only if the provided key does not exist.
      Parameters:
      map - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • get

      @Nullable V get(Object key)
      Get the value of key.
      Parameters:
      key - must not be null.
      Returns:
      null when key does not exist or used in pipeline / transaction.
      See Also:
    • getAndDelete

      @Nullable V getAndDelete(K key)
      Return the value at key and delete the key.
      Parameters:
      key - must not be null.
      Returns:
      null when key does not exist or used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • getAndExpire

      @Nullable V getAndExpire(K key, long timeout, TimeUnit unit)
      Return the value at key and expire the key by applying timeout.
      Parameters:
      key - must not be null.
      timeout -
      unit - must not be null.
      Returns:
      null when key does not exist or used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • getAndExpire

      @Nullable V getAndExpire(K key, Duration timeout)
      Return the value at key and expire the key by applying timeout.
      Parameters:
      key - must not be null.
      timeout - must not be null.
      Returns:
      null when key does not exist or used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • getAndPersist

      @Nullable V getAndPersist(K key)
      Return the value at key and persist the key. This operation removes any TTL that is associated with key.
      Parameters:
      key - must not be null.
      Returns:
      null when key does not exist or used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • getAndSet

      @Nullable V getAndSet(K key, V value)
      Set value of key and return its old value.
      Parameters:
      key - must not be null.
      Returns:
      null when key does not exist or used in pipeline / transaction.
      See Also:
    • multiGet

      @Nullable List<V> multiGet(Collection<K> keys)
      Get multiple keys. Values are in the order of the requested keys Absent field values are represented using null in the resulting List.
      Parameters:
      keys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • increment

      @Nullable Long increment(K key)
      Increment an integer value stored as string value under key by one.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.1
      See Also:
    • increment

      @Nullable Long increment(K key, long delta)
      Increment an integer value stored as string value under key by delta.
      Parameters:
      key - must not be null.
      delta -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • increment

      @Nullable Double increment(K key, double delta)
      Increment a floating point number value stored as string value under key by delta.
      Parameters:
      key - must not be null.
      delta -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • decrement

      @Nullable Long decrement(K key)
      Decrement an integer value stored as string value under key by one.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.1
      See Also:
    • decrement

      @Nullable Long decrement(K key, long delta)
      Decrement an integer value stored as string value under key by delta.
      Parameters:
      key - must not be null.
      delta -
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.1
      See Also:
    • append

      @Nullable Integer append(K key, String value)
      Append a value to key.
      Parameters:
      key - must not be null.
      value -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • get

      @Nullable String get(K key, long start, long end)
      Get a substring of value of key between begin and end.
      Parameters:
      key - must not be null.
      start -
      end -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • set

      void set(K key, V value, long offset)
      Overwrite parts of key starting at the specified offset with given value.
      Parameters:
      key - must not be null.
      value -
      offset -
      See Also:
    • size

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

      @Nullable Boolean setBit(K key, long offset, boolean value)
      Sets the bit at offset in value stored at key.
      Parameters:
      key - must not be null.
      offset -
      value -
      Returns:
      null when used in pipeline / transaction.
      Since:
      1.5
      See Also:
    • getBit

      @Nullable Boolean getBit(K key, long offset)
      Get the bit value at offset of value at key.
      Parameters:
      key - must not be null.
      offset -
      Returns:
      null when used in pipeline / transaction.
      Since:
      1.5
      See Also:
    • bitField

      @Nullable List<Long> bitField(K key, BitFieldSubCommands subCommands)
      Get / Manipulate specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset stored at a given key.
      Parameters:
      key - must not be null.
      subCommands - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.1
      See Also:
    • getOperations

      RedisOperations<K,V> getOperations()