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, Yordan Tsintsov
-
Method Summary
Modifier and TypeMethodDescriptionAppend avaluetokey.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 givenkey.compareAndSet(@NonNull K key, @NonNull V expectedValue, @NonNull V newValue) Compare the value atkeywithexpectedValueand set it tonewValueif they are equal.Decrement an integer value stored as string value underkeyby one.Decrement an integer value stored as string value underkeybydelta.Get a substring of value ofkeybetweenbeginandend.@Nullable VGet the value ofkey.@Nullable VgetAndDelete(@NonNull K key) Return the value atkeyand delete the key.@Nullable VgetAndExpire(@NonNull K key, long timeout, @NonNull TimeUnit unit) Deprecated.@Nullable VgetAndExpire(@NonNull K key, @NonNull Duration timeout) Return the value atkeyand expire the key by applyingtimeout.getAndExpire(@NonNull K key, @NonNull Expiration expiration) Return the value atkeyand expire the key by applyingexpiration.@Nullable VgetAndPersist(@NonNull K key) Return the value atkeyand persist the key.@Nullable VSetvalueofkeyand return its old value.Get the bit value atoffsetof value atkey.@NonNull RedisOperations<K, V> Increment an integer value stored as string value underkeyby one.Increment a floating point number value stored as string value underkeybydelta.Increment an integer value stored as string value underkeybydelta.multiGet(@NonNull Collection<@NonNull K> keys) Get multiplekeys.voidSet multiple keys to multiple values using key-value pairs provided intuple.multiSetIfAbsent(Map<? extends @NonNull K, ? extends @NonNull V> map) Set multiple keys to multiple values using key-value pairs provided intupleonly if the provided key does not exist.voidSetvalueforkey.voidOverwrite parts ofkeystarting at the specifiedoffsetwith givenvalue.default voidDeprecated.since 4.1 in favor ofset(Object, Object, Expiration)default voidSet thevalueand expirationtimeoutforkey.set(@NonNull K key, @NonNull V value, @NonNull Consumer<SetSpec<@NonNull K, @NonNull V>> setConsumer) voidset(@NonNull K key, @NonNull V value, @NonNull Expiration expiration) Set thevalueandexpirationforkey.Sets the bit atoffsetin value stored atkey.default @Nullable VDeprecated.since 4.1 in favor ofsetGet(Object, Object, Expiration).default @Nullable VSet thevalueand expirationtimeoutforkey.setGet(@NonNull K key, @NonNull V value, @NonNull Consumer<SetSpec<@NonNull K, @NonNull V>> setConsumer) @Nullable VsetGet(@NonNull K key, @NonNull V value, @NonNull Expiration expiration) Set thevalueandexpirationforkey.default BooleansetIfAbsent(@NonNull K key, @NonNull V value) Set thevalueforkeyifkeyis absent.default BooleansetIfAbsent(@NonNull K key, @NonNull V value, long timeout, @NonNull TimeUnit unit) Deprecated.since 4.1 in favor ofsetIfAbsent(Object, Object, Expiration).default BooleansetIfAbsent(@NonNull K key, @NonNull V value, @NonNull Duration timeout) Set thevalueand expirationtimeoutforkeyifkeyis absent.setIfAbsent(@NonNull K key, @NonNull V value, @NonNull Expiration expiration) Set thevalueandexpirationforkeyifkeyis absent.default BooleansetIfPresent(@NonNull K key, @NonNull V value) Set thevalueforkeyifkeyis present.default BooleansetIfPresent(@NonNull K key, @NonNull V value, long timeout, @NonNull TimeUnit unit) Deprecated.since 4.1 in favor ofsetIfPresent(Object, Object, Expiration).default BooleansetIfPresent(@NonNull K key, @NonNull V value, @NonNull Duration timeout) Set thevalueand expirationtimeoutforkeyifkeyis present.setIfPresent(@NonNull K key, @NonNull V value, @NonNull Expiration expiration) Set thevalueandexpirationforkeyifkeyis present.Get the length of the value stored atkey.
-
Method Details
-
set
-
set
Set thevalueandexpirationforkey.- Parameters:
key- must not be null.value- must not be null.expiration- must not be null.- Since:
- 4.1
- See Also:
-
set
@Deprecated(since="4.1") default void set(@NonNull K key, @NonNull V value, long timeout, @NonNull TimeUnit unit) Deprecated.since 4.1 in favor ofset(Object, Object, Expiration)Set thevalueand expirationtimeoutforkey.- Parameters:
key- must not be null.value- must not be null.timeout- the key expiration timeout.unit- must not be null.- See Also:
-
set
Set thevalueand expirationtimeoutforkey.- Parameters:
key- must not be null.value- must not be null.timeout- must not be null.- Throws:
IllegalArgumentException- if eitherkey,valueortimeoutis not present.- Since:
- 2.1
- See Also:
-
set
Boolean set(@NonNull K key, @NonNull V value, @NonNull Consumer<SetSpec<@NonNull K, @NonNull V>> setConsumer) - Parameters:
key- must not be null.value- must not be null.setConsumer- a function that consumes theSetSpecto configure the set operation, must not be null.- Returns:
- true if the operation was successful, false otherwise. null when used in pipeline / transaction.
- Since:
- 4.1
- See Also:
-
setGet
Set thevalueandexpirationforkey. 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.expiration- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 4.1
- See Also:
-
setGet
@Deprecated(since="4.1") default @Nullable V setGet(@NonNull K key, @NonNull V value, long timeout, @NonNull TimeUnit unit) Deprecated.since 4.1 in favor ofsetGet(Object, Object, Expiration).Set thevalueand expirationtimeoutforkey. 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
Set thevalueand expirationtimeoutforkey. 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:
-
setGet
V setGet(@NonNull K key, @NonNull V value, @NonNull Consumer<SetSpec<@NonNull K, @NonNull V>> setConsumer) Setvalueforkeyand customize the operation throughSetSpec. Return the old string stored at key, or null if key did not exist.- Parameters:
key- must not be null.value- must not be null.setConsumer- a function that consumes theSetSpecto configure the set operation, must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 4.1
- See Also:
-
setIfAbsent
-
setIfAbsent
Set thevalueandexpirationforkeyifkeyis absent.- Parameters:
key- must not be null.value- must not be null.expiration- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 4.1
- See Also:
-
setIfAbsent
@Deprecated(since="4.1") default Boolean setIfAbsent(@NonNull K key, @NonNull V value, long timeout, @NonNull TimeUnit unit) Deprecated.since 4.1 in favor ofsetIfAbsent(Object, Object, Expiration).Set thevalueand expirationtimeoutforkeyifkeyis 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
Set thevalueand expirationtimeoutforkeyifkeyis 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 eitherkey,valueortimeoutis not present.- Since:
- 2.1
- See Also:
-
setIfPresent
Set thevalueforkeyifkeyis 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 eitherkeyorvalueis not present.- Since:
- 2.1
- See Also:
-
setIfPresent
Set thevalueandexpirationforkeyifkeyis present.- Parameters:
key- must not be null.value- must not be null.expiration- must not be null.- Returns:
- command result indicating if the key has been set.
- Since:
- 4.1
- See Also:
-
setIfPresent
@Deprecated(since="4.1") default Boolean setIfPresent(@NonNull K key, @NonNull V value, long timeout, @NonNull TimeUnit unit) Deprecated.since 4.1 in favor ofsetIfPresent(Object, Object, Expiration).Set thevalueand expirationtimeoutforkeyifkeyis 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 eitherkey,valueortimeoutis not present.- Since:
- 2.1
- See Also:
-
setIfPresent
Set thevalueand expirationtimeoutforkeyifkeyis 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 eitherkey,valueortimeoutis not present.- Since:
- 2.1
- See Also:
-
compareAndSet
Compare the value atkeywithexpectedValueand set it tonewValueif they are equal. Useset(Object, Object, Consumer)to customize the set operation using e.g. a different value comparison strategy.- Parameters:
key- must not be null.expectedValue- the expected current value, must not be null.newValue- the new value to set if comparison succeeds, must not be null.- Returns:
- true if the operation was successful, false otherwise. null when used in pipeline / transaction.
- Since:
- 4.1
- See Also:
-
multiSet
-
multiSetIfAbsent
-
get
-
getAndDelete
-
getAndExpire
Return the value atkeyand expire the key by applyingexpiration.- Parameters:
key- must not be null.expiration- must not be null.- Returns:
- null when key does not exist or used in pipeline / transaction.
- Since:
- 4.1
- See Also:
-
getAndExpire
@Deprecated(since="4.1") @Nullable V getAndExpire(@NonNull K key, long timeout, @NonNull TimeUnit unit) Deprecated.since 4.1 in favor ofgetAndExpire(Object, Expiration).Return the value atkeyand expire the key by applyingtimeout.- 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
-
getAndPersist
-
getAndSet
-
multiGet
Get multiplekeys. Values are in the order of the requested keys Absent field values are represented using null in the resultingList.- Parameters:
keys- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
increment
-
increment
-
increment
-
decrement
-
decrement
-
append
-
get
-
set
-
size
-
setBit
-
getBit
-
bitField
Get / Manipulate specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset stored at a givenkey.- 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
RedisOperationsused to execute commands.
-
getAndExpire(Object, Expiration).