Interface BoundHashOperations<H,HK,HV>
- All Superinterfaces:
BoundKeyOperations<H>
Hash operations bound to a certain key.
- Author:
- Costin Leau, Christoph Strobl, Ninad Divadkar, Mark Paluch, Tihomir Mateev
-
Method Summary
Modifier and TypeMethodDescriptionDelete given hashkeysat the bound key.entries()Get entire hash at the bound key.Get value for givenkeyfrom the hash at the bound key.getAndDelete(@NonNull Collection<@NonNull HK> hashFields) Get and remove the value for givenhashFieldsfrom the hash at the bound key.getAndExpire(@Nullable Expiration expiration, @NonNull Collection<@NonNull HK> hashFields) Get and optionally expire the value for givenhashFieldsfrom the hash at the bound key.@NonNull RedisOperations<H, ?> default @NonNull BoundHashFieldExpirationOperations<HK> Returns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundkey.default @NonNull BoundHashFieldExpirationOperations<HK> hashExpiration(@NonNull HK @NonNull ... hashFields) Returns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundkeyfor the given hash fields.default @NonNull BoundHashFieldExpirationOperations<HK> hashExpiration(@NonNull Collection<@NonNull HK> hashFields) Returns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundkeyfor the given hash fields.Determine if given hashkeyexists at the bound key.Incrementvalueof a hashkeyby the givendeltaat the bound key.Incrementvalueof a hashkeyby the givendeltaat the bound key.keys()Get key set (fields) of hash at the bound key.lengthOfValue(@NonNull HK hashKey) Returns the length of the value associated withhashKey.multiGet(@NonNull Collection<@NonNull HK> keys) Get values for givenkeysfrom the hash at the bound key.voidSet thevalueof a hashkeyat the bound key.voidSet multiple hash fields to multiple values using data provided inmat the bound key.voidputAndExpire(Map<? extends @NonNull HK, ? extends HV> m, @NonNull RedisHashCommands.HashFieldSetOption condition, @Nullable Expiration expiration) Set the value of one or more fields using data provided inmat the bound key, and optionally set their expiration time or time-to-live (TTL).putIfAbsent(@NonNull HK key, HV value) Set thevalueof a hashkeyonly ifkeydoes not exist.randomEntries(long count) Return a random entry from the hash stored at the bound key.Return a random entry from the hash stored at the bound key.Return a random key from the hash stored at the bound key.randomKeys(long count) Return a random keys from the hash stored at the bound key.scan(@NonNull ScanOptions options) Use aCursorto iterate over entries in hash at the bound key.size()Get size of hash at the bound key.values()Get entry set (values) of hash at the bound key.
-
Method Details
-
delete
-
hasKey
-
get
-
multiGet
Get values for givenkeysfrom the hash at the bound key. 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.
-
increment
-
increment
-
randomKey
HK randomKey()Return a random key from the hash stored at the bound key.- Returns:
- null if the hash does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
randomEntry
-
randomKeys
Return a random keys from the hash stored at the bound key. If the providedcountargument is positive, return a list of distinct keys, capped either atcountor the hash size. Ifcountis negative, the behavior changes and the command is allowed to return the same key multiple times. In this case, the number of returned keys is the absolute value of the specified count.- Parameters:
count- number of keys to return.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
randomEntries
-
keys
-
lengthOfValue
-
size
-
putAll
-
put
-
putIfAbsent
-
values
-
entries
-
scan
Use aCursorto iterate over entries in hash at the bound key.
Important: CallCloseableIterator.close()when done to avoid resource leaks.- Parameters:
options- must not be null.- Returns:
- the result cursor providing access to the scan result. Must be closed once fully processed (e.g. through a try-with-resources clause).
- Since:
- 1.4
-
hashExpiration
Returns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundkey. Operations on the expiration object obtain keys at the time of invoking any expiration operation.- Returns:
- the bound operations object to perform operations on the hash field expiration.
- Since:
- 3.5
-
hashExpiration
default @NonNull BoundHashFieldExpirationOperations<HK> hashExpiration(@NonNull HK @NonNull ... hashFields) Returns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundkeyfor the given hash fields.- Parameters:
hashFields- collection of hash fields to operate on.- Returns:
- the bound operations object to perform operations on the hash field expiration.
- Since:
- 3.5
-
hashExpiration
default @NonNull BoundHashFieldExpirationOperations<HK> hashExpiration(@NonNull Collection<@NonNull HK> hashFields) Returns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundkeyfor the given hash fields.- Parameters:
hashFields- collection of hash fields to operate on.- Returns:
- the bound operations object to perform operations on the hash field expiration.
- Since:
- 3.5
-
getOperations
@NonNull RedisOperations<H,?> getOperations()- Specified by:
getOperationsin interfaceBoundKeyOperations<H>- Returns:
- the underlying
RedisOperationsused to execute commands.
-
getAndDelete
Get and remove the value for givenhashFieldsfrom the hash at the bound key. Values are in the order of the requested hash fields. Absent field values are represented using null in the resultingList.- Parameters:
hashFields- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 4.0
- See Also:
-
getAndExpire
Get and optionally expire the value for givenhashFieldsfrom the hash at the bound key. Values are in the order of the requested hash fields. Absent field values are represented using null in the resultingList.- Parameters:
expiration- is optional.hashFields- must not be null.- Returns:
- never null.
- Since:
- 4.0
- See Also:
-
putAndExpire
void putAndExpire(Map<? extends @NonNull HK, ? extends HV> m, @NonNull RedisHashCommands.HashFieldSetOption condition, @Nullable Expiration expiration) Set the value of one or more fields using data provided inmat the bound key, and optionally set their expiration time or time-to-live (TTL). Theconditiondetermines whether the fields are set.- Parameters:
m- must not be null.condition- must not be null. UseRedisHashCommands.HashFieldSetOption.IF_NONE_EXIST(FNX) to only set the fields if none of them already exist,RedisHashCommands.HashFieldSetOption.IF_ALL_EXIST(FXX) to only set the fields if all of them already exist, orRedisHashCommands.HashFieldSetOption.UPSERTto set the fields unconditionally.expiration- is optional.- Since:
- 4.0
- See Also:
-