Interface ReactiveHashOperations<H,HK,HV>
public interface ReactiveHashOperations<H,HK,HV>
Reactive Redis operations for Hash Commands.
Streams of methods returning Mono<K>
or Flux<M>
are terminated with
InvalidDataAccessApiUsageException
when
RedisElementReader.read(ByteBuffer)
returns null for a
particular element as Reactive Streams prohibit the usage of null values.
- Since:
- 2.0
- Author:
- Mark Paluch, Christoph Strobl
-
Method Summary
Modifier and TypeMethodDescriptionRemoves the given key.Get entire hash stored atkey
.expire
(H key, Duration timeout, Collection<HK> hashKeys) Set time to live for given hashKeys stored within key.expire
(H key, Expiration expiration, ExpirationOptions options, Collection<HK> hashKeys) Set time to live for given hashKeys stored within key.expireAt
(H key, Instant expireAt, Collection<HK> hashKeys) Set the expiration for givenhashKey
as a date timestamp.Get value for givenhashKey
from hash atkey
.default Mono<Expirations<HK>>
getTimeToLive
(H key, Collection<HK> hashKeys) Get the time to live forhashKey
in seconds.getTimeToLive
(H key, TimeUnit timeUnit, Collection<HK> hashKeys) Get the time to live forhashKey
and convert it to the givenTimeUnit
.Determine if given hashhashKey
exists.Incrementvalue
of a hashhashKey
by the givendelta
.Incrementvalue
of a hashhashKey
by the givendelta
.Get key set (fields) of hash atkey
.multiGet
(H key, Collection<HK> hashKeys) Get values for givenhashKeys
from hash atkey
.persist
(H key, Collection<HK> hashKeys) Remove the expiration from givenhashKey
.Set thevalue
of a hashhashKey
.Set multiple hash fields to multiple values using data provided inm
.putIfAbsent
(H key, HK hashKey, HV value) Set thevalue
of a hashhashKey
only ifhashKey
does not exist.randomEntries
(H key, long count) Return 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
.Delete given hashhashKeys
from the hash at key.Use aFlux
to iterate over entries in the hash atkey
.scan
(H key, ScanOptions options) Get size of hash atkey
.Get entry set (values) of hash atkey
.
-
Method Details
-
remove
Delete given hashhashKeys
from the hash at key.- Parameters:
key
- must not be null.hashKeys
- must not be null.- Returns:
-
hasKey
Determine if given hashhashKey
exists.- Parameters:
key
- must not be null.hashKey
- must not be null.- Returns:
-
get
Get value for givenhashKey
from hash atkey
.- Parameters:
key
- must not be null.hashKey
- must not be null.- Returns:
-
multiGet
Get values for givenhashKeys
from 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:
-
increment
Incrementvalue
of a hashhashKey
by the givendelta
.- Parameters:
key
- must not be null.hashKey
- must not be null.delta
-- Returns:
-
increment
Incrementvalue
of a hashhashKey
by the givendelta
.- Parameters:
key
- must not be null.hashKey
- must not be null.delta
-- Returns:
-
randomKey
Return a random hash key from the hash stored atkey
.- Parameters:
key
- must not be null.- Returns:
- Since:
- 2.6
- See Also:
-
randomEntry
Return a random entry from the hash stored atkey
.- Parameters:
key
- must not be null.- Returns:
- Since:
- 2.6
- See Also:
-
randomKeys
Return random hash keys from the hash stored atkey
. If the providedcount
argument is positive, return a list of distinct hash keys, capped either atcount
or the hash size. Ifcount
is 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:
- Since:
- 2.6
- See Also:
-
randomEntries
Return random entries from the hash stored atkey
. If the providedcount
argument is positive, return a list of distinct entries, capped either atcount
or the hash size. Ifcount
is negative, the behavior changes and the command is allowed to return the same entry 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:
-
keys
Get key set (fields) of hash atkey
.- Parameters:
key
- must not be null.- Returns:
-
size
Get size of hash atkey
.- Parameters:
key
- must not be null.- Returns:
-
putAll
Set multiple hash fields to multiple values using data provided inm
.- Parameters:
key
- must not be null.map
- must not be null.
-
put
Set thevalue
of a hashhashKey
.- Parameters:
key
- must not be null.hashKey
- must not be null.value
-
-
putIfAbsent
Set thevalue
of a hashhashKey
only ifhashKey
does not exist.- Parameters:
key
- must not be null.hashKey
- must not be null.value
-- Returns:
-
values
Get entry set (values) of hash atkey
.- Parameters:
key
- must not be null.- Returns:
-
entries
Get entire hash stored atkey
.- Parameters:
key
- must not be null.- Returns:
-
scan
Use aFlux
to iterate over entries in the hash atkey
. The resultingFlux
acts as a cursor and issuesHSCAN
commands itself as long as the subscriber signals demand.- Parameters:
key
- must not be null.- Returns:
- the
Flux
emitting theentries
on by one or anempty flux
if the key does not exist. - Throws:
IllegalArgumentException
- when the givenkey
is null.- Since:
- 2.1
- See Also:
-
scan
Use aFlux
to iterate over entries in the hash atkey
givenScanOptions
. The resultingFlux
acts as a cursor and issuesHSCAN
commands itself as long as the subscriber signals demand.- Parameters:
key
- must not be null.options
- must not be null. UseScanOptions.NONE
instead.- Returns:
- the
Flux
emitting theentries
on by one or anempty flux
if the key does not exist. - Throws:
IllegalArgumentException
- when one of the required arguments is null.- Since:
- 2.1
- See Also:
-
expire
Set time to live for given hashKeys stored within key.- 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:
- a
Mono
emitting changes to the hash fields. - Throws:
IllegalArgumentException
- if the timeout is null.- Since:
- 3.5
- See Also:
-
expire
Mono<ExpireChanges<HK>> expire(H key, Expiration expiration, ExpirationOptions options, Collection<HK> hashKeys) Set time to live for given hashKeys stored within key.- Parameters:
key
- must not be null.expiration
- must not be null.options
- additional options to apply.hashKeys
- must not be null.- Returns:
- a
Mono
emitting changes to the hash fields. - Throws:
IllegalArgumentException
- if the timeout is null.- Since:
- 3.5
- See Also:
-
expireAt
Set the expiration for givenhashKey
as a date timestamp.- Parameters:
key
- must not be null.expireAt
- must not be null.hashKeys
- must not be null.- Returns:
- a
Mono
emitting changes to the hash fields. - Throws:
IllegalArgumentException
- if the instant is null or too large to represent as aDate
.- Since:
- 3.5
- See Also:
-
persist
Remove the expiration from givenhashKey
.- Parameters:
key
- must not be null.hashKeys
- must not be null.- Returns:
- a
Mono
emitting changes to the hash fields. - Since:
- 3.5
- See Also:
-
getTimeToLive
Get the time to live forhashKey
in seconds.- Parameters:
key
- must not be null.hashKeys
- must not be null.- Returns:
- a
Mono
emittingExpirations
of the hash fields. - Since:
- 3.5
- See Also:
-
getTimeToLive
Get the time to live forhashKey
and convert it to the givenTimeUnit
.- Parameters:
key
- must not be null.timeUnit
- must not be null.hashKeys
- must not be null.- Returns:
- a
Mono
emittingExpirations
of the hash fields. - Since:
- 3.5
- See Also:
-
delete
Removes the given key.- Parameters:
key
- must not be null.
-