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, JaeGeun Lee
-
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.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 ofkeybetweenstartandend.Get the value ofkey.getAndDelete(@NonNull K key) Return the value atkeyand delete the key.getAndExpire(@NonNull K key, long timeout, @NonNull TimeUnit unit) Deprecated.getAndExpire(@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.getAndPersist(@NonNull K key) Return the value atkeyand persist the key.Setvalueofkeyand return its old value.Get the bit value atoffsetof value atkey.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.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 thevalueandexpirationforkey.Sets the bit atoffsetin value stored atkey.Deprecated.since 4.1 in favor ofsetGet(Object, Object, Expiration).Set thevalueand expirationtimeoutforkey.setGet(@NonNull K key, @NonNull V value, @NonNull Consumer<SetSpec<@NonNull K, @NonNull V>> setConsumer) Set thevalueandexpirationforkey.default BooleansetIfAbsent(@NonNull K key, @NonNull V value) Set thevalueforkeyifkeyis absent.default BooleanDeprecated.since 4.1 in favor ofsetIfAbsent(Object, Object, Expiration).default BooleanSet 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 BooleanDeprecated.since 4.1 in favor ofsetIfPresent(Object, Object, Expiration).default BooleanSet 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
@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
-
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).