Interface ValueOperations<K,V>


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

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

    • set

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

      @Nullable V setGet(@NonNull K key, @NonNull V value, long timeout, @NonNull TimeUnit unit)
      Set the value and expiration timeout for key. Return the old string stored at key, or null if key did not exist. An error is returned and SET aborted if the value stored at key is not a string.
      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:
      3.5
      See Also:
    • setGet

      @Nullable V setGet(@NonNull K key, @NonNull V value, @NonNull Duration duration)
      Set the value and expiration timeout for key. Return the old string stored at key, or null if key did not exist. An error is returned and SET aborted if the value stored at key is not a string.
      Parameters:
      key - must not be null.
      value - must not be null.
      duration - expiration duration
      Returns:
      null when used in pipeline / transaction.
      Since:
      3.5
      See Also:
    • set

      void set(@NonNull K key, @NonNull V value, long timeout, @NonNull 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(@NonNull K key, @NonNull V value, @NonNull 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

      Boolean setIfAbsent(@NonNull K key, @NonNull 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

      Boolean setIfAbsent(@NonNull K key, @NonNull V value, long timeout, @NonNull 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

      default Boolean setIfAbsent(@NonNull K key, @NonNull V value, @NonNull 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

      Boolean setIfPresent(@NonNull K key, @NonNull 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

      Boolean setIfPresent(@NonNull K key, @NonNull V value, long timeout, @NonNull 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

      default Boolean setIfPresent(@NonNull K key, @NonNull V value, @NonNull 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 @NonNull K, ? extends @NonNull V> map)
      Set multiple keys to multiple values using key-value pairs provided in tuple.
      Parameters:
      map - must not be null.
      See Also:
    • multiSetIfAbsent

      Boolean multiSetIfAbsent(Map<? extends @NonNull K, ? extends @NonNull 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(@NonNull 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(@NonNull K key, long timeout, @NonNull 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(@NonNull K key, @NonNull 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(@NonNull 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(@NonNull K key, @NonNull 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

      List<@Nullable V> multiGet(@NonNull Collection<@NonNull 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

      Long increment(@NonNull 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

      Long increment(@NonNull 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

      Double increment(@NonNull 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

      Long decrement(@NonNull 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

      Long decrement(@NonNull 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

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

      String get(@NonNull 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(@NonNull K key, @NonNull 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

      Long size(@NonNull 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

      Boolean setBit(@NonNull 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

      Boolean getBit(@NonNull 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

      List<Long> bitField(@NonNull K key, @NonNull 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

      @NonNull RedisOperations<K,V> getOperations()
      Returns:
      the underlying RedisOperations used to execute commands.