Module spring.data.redis
Interface HashOperations<H,HK,HV>
public interface HashOperations<H,HK,HV>
Redis map specific operations working on a hash.
- Author:
- Costin Leau, Christoph Strobl, Ninad Divadkar, Tihomir Mateev
-
Method Summary
Modifier and TypeMethodDescriptionDelete given hashhashKeys.Get entire hash stored atkey.default BoundHashFieldExpirationOperations<HK>expiration(H key) Returns a bound operations object to perform operations on the hash field expiration for all hash fields atkey.default BoundHashFieldExpirationOperations<HK>expiration(H key, HK... hashFields) Returns a bound operations object to perform operations on the hash field expiration for all hash fields atkeyfor the given hash fields.default BoundHashFieldExpirationOperations<HK>expiration(H key, Collection<HK> hashFields) Returns a bound operations object to perform operations on the hash field expiration for all hash fields atkeyfor the given hash fields.expire(H key, Duration timeout, Collection<HK> hashKeys) Set time to live for givenhashKey.expire(H key, Expiration expiration, ExpirationOptions options, Collection<HK> hashKeys) Apply the expiration for givenhashKeys.expireAt(H key, Instant expireAt, Collection<HK> hashKeys) Set the expiration for givenhashKeysas a date timestamp.Get value for givenhashKeyfrom hash atkey.RedisOperations<H,?> default Expirations<HK>getTimeToLive(H key, Collection<HK> hashKeys) Get the time to live forhashKeysin seconds.getTimeToLive(H key, TimeUnit timeUnit, Collection<HK> hashKeys) Get the time to live forhashKeysand convert it to the givenTimeUnit.Determine if given hashhashKeyexists.Incrementvalueof a hashhashKeyby the givendelta.Incrementvalueof a hashhashKeyby the givendelta.Get key set (fields) of hash atkey.lengthOfValue(H key, HK hashKey) Returns the length of the value associated withhashKey.multiGet(H key, Collection<HK> hashKeys) Get values for givenhashKeysfrom hash atkey.persist(H key, Collection<HK> hashKeys) Remove the expiration from givenhashKeys.voidSet thevalueof a hashhashKey.voidSet multiple hash fields to multiple values using data provided inm.putIfAbsent(H key, HK hashKey, HV value) Set thevalueof a hashhashKeyonly ifhashKeydoes not exist.randomEntries(H key, long count) Return a random entries from the hash stored atkey.randomEntry(H key) Return a random entry from the hash stored atkey.Return a random hash key from the hash stored atkey.randomKeys(H key, long count) Return random hash keys from the hash stored atkey.scan(H key, ScanOptions options) Use aCursorto iterate over entries in hash atkey.Get size of hash atkey.Get entry set (values) of hash atkey.
-
Method Details
-
delete
Delete given hashhashKeys.- Parameters:
key- must not be null.hashKeys- must not be null.- Returns:
- null when used in pipeline / transaction.
-
hasKey
Determine if given hashhashKeyexists.- Parameters:
key- must not be null.hashKey- must not be null.- Returns:
- null when used in pipeline / transaction.
-
get
Get value for givenhashKeyfrom hash atkey.- Parameters:
key- must not be null.hashKey- must not be null.- Returns:
- null when key or hashKey does not exist or used in pipeline / transaction.
-
multiGet
Get values for givenhashKeysfrom hash atkey. Values are in the order of the requested keys Absent field values are represented using null in the resultingList.- Parameters:
key- must not be null.hashKeys- must not be null.- Returns:
- null when used in pipeline / transaction.
-
increment
Incrementvalueof a hashhashKeyby the givendelta.- Parameters:
key- must not be null.hashKey- must not be null.delta-- Returns:
- null when used in pipeline / transaction.
-
increment
Incrementvalueof a hashhashKeyby the givendelta.- Parameters:
key- must not be null.hashKey- must not be null.delta-- Returns:
- null when used in pipeline / transaction.
-
randomKey
Return a random hash key from the hash stored atkey.- Parameters:
key- must not be null.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
randomEntry
Return a random entry from the hash stored atkey.- Parameters:
key- must not be null.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
randomKeys
Return random hash keys from the hash stored atkey. If the providedcountargument is positive, return a list of distinct hash keys, capped either atcountor the hash size. Ifcountis negative, the behavior changes and the command is allowed to return the same hash key multiple times. In this case, the number of returned fields is the absolute value of the specified count.- Parameters:
key- must not be null.count- number of fields to return.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
randomEntries
Return a random entries from the hash stored atkey.- Parameters:
key- must not be null.count- number of fields to return. Must be positive.- Returns:
- null if key does not exist or when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
keys
Get key set (fields) of hash atkey.- Parameters:
key- must not be null.- Returns:
- null when used in pipeline / transaction.
-
lengthOfValue
Returns the length of the value associated withhashKey. If either thekeyor thehashKeydo not exist,0is returned.- Parameters:
key- must not be null.hashKey- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.1
-
size
Get size of hash atkey.- Parameters:
key- must not be null.- Returns:
- null when used in pipeline / transaction.
-
putAll
Set multiple hash fields to multiple values using data provided inm.- Parameters:
key- must not be null.m- must not be null.
-
put
Set thevalueof a hashhashKey.- Parameters:
key- must not be null.hashKey- must not be null.value-
-
putIfAbsent
Set thevalueof a hashhashKeyonly ifhashKeydoes not exist.- Parameters:
key- must not be null.hashKey- must not be null.value-- Returns:
- null when used in pipeline / transaction.
-
values
Get entry set (values) of hash atkey.- Parameters:
key- must not be null.- Returns:
- null when used in pipeline / transaction.
-
entries
Get entire hash stored atkey.- Parameters:
key- must not be null.- Returns:
- null when used in pipeline / transaction.
-
scan
Use aCursorto iterate over entries in hash atkey.
Important: CallCloseableIterator.close()when done to avoid resource leaks.- Parameters:
key- must not be null.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
-
expire
Set time to live for givenhashKey.- Parameters:
key- must not be null.timeout- the amount of time after which the key will be expired, must not be null.hashKeys- must not be null.- Returns:
- changes to the hash fields. null when used in pipeline / transaction.
- Throws:
IllegalArgumentException- if the timeout is null.- Since:
- 3.5
- See Also:
-
expireAt
Set the expiration for givenhashKeysas a date timestamp.- Parameters:
key- must not be null.expireAt- must not be null.hashKeys- must not be null.- Returns:
- changes to the hash fields. null when used in pipeline / transaction.
- Throws:
IllegalArgumentException- if the instant is null or too large to represent as aDate.- Since:
- 3.5
- See Also:
-
expire
@Nullable ExpireChanges<HK> expire(H key, Expiration expiration, ExpirationOptions options, Collection<HK> hashKeys) Apply the expiration for givenhashKeys.- Parameters:
key- must not be null.expiration- must not be null.options- must not be null.hashKeys- must not be null.- Returns:
- changes to the hash fields. null when used in pipeline / transaction.
- Throws:
IllegalArgumentException- if the instant is null or too large to represent as aDate.- Since:
- 3.5
- See Also:
-
persist
Remove the expiration from givenhashKeys.- Parameters:
key- must not be null.hashKeys- must not be null.- Returns:
- changes to the hash fields. null when used in pipeline / transaction.
- Since:
- 3.5
- See Also:
-
getTimeToLive
Get the time to live forhashKeysin seconds.- Parameters:
key- must not be null.hashKeys- must not be null.- Returns:
- the actual expirations in seconds for the hash fields. null when used in pipeline / transaction.
- Since:
- 3.5
- See Also:
-
getTimeToLive
Get the time to live forhashKeysand convert it to the givenTimeUnit.- Parameters:
key- must not be null.timeUnit- must not be null.hashKeys- must not be null.- Returns:
- the actual expirations for the hash fields. null when used in pipeline / transaction.
- Since:
- 3.5
- See Also:
-
expiration
Returns a bound operations object to perform operations on the hash field expiration for all hash fields atkey. Operations on the expiration object obtain keys at the time of invoking any expiration operation.- Parameters:
key- must not be null.- Returns:
- the bound operations object to perform operations on the hash field expiration.
- Since:
- 3.5
-
expiration
Returns a bound operations object to perform operations on the hash field expiration for all hash fields atkeyfor 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
-
expiration
Returns a bound operations object to perform operations on the hash field expiration for all hash fields atkeyfor 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
RedisOperations<H,?> getOperations()- Returns:
- never null.
-