Interface ReactiveKeyCommands
- All Known Subinterfaces:
ReactiveClusterKeyCommands
public interface ReactiveKeyCommands
Redis Key commands executed using reactive infrastructure.
- Since:
- 2.0
- Author:
- Christoph Strobl, Mark Paluch, Dahye Anne Lee
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
MOVE
command parameters.static class
EXPIREAT
/PEXPIREAT
command parameters.static class
EXPIRE
/PEXPIRE
command parameters.static class
MOVE
command parameters.static class
RENAME
command parameters. -
Method Summary
Modifier and TypeMethodDescriptioncopy
(ByteBuffer sourceKey, ByteBuffer targetKey, boolean replace) Copy givenkey
to a targetkey
.copy
(Publisher<ReactiveKeyCommands.CopyCommand> commands) Copy keys one-by-one.del
(ByteBuffer key) Delete key.Delete keys one by one.encodingOf
(ByteBuffer key) Get the type of internal representation used for storing the value at the givenkey
.exists
(ByteBuffer key) Determine if given key exists.exists
(List<ByteBuffer> keys) Determine the number of given keys that exist.Determine if given key exists.expire
(ByteBuffer key, Duration timeout) Set time to live for givenkey
in seconds.expire
(Publisher<ReactiveKeyCommands.ExpireCommand> commands) Expire keys one by one.expireAt
(ByteBuffer key, Instant expireAt) Set the expiration for givenkey
as a UNIX timestamp.expireAt
(Publisher<ReactiveKeyCommands.ExpireAtCommand> commands) Set one-by-one the expiration for givenkey
as a UNIX timestamp.idletime
(ByteBuffer key) Get theDuration
since the object stored at the givenkey
is idle.default Mono<List<ByteBuffer>>
keys
(ByteBuffer pattern) Find all keys matching the given pattern.
It is recommended to usescan(ScanOptions)
to iterate over the keyspace askeys(ByteBuffer)
is a non-interruptible and expensive Redis operation.keys
(Publisher<ByteBuffer> patterns) Find all keys matching the given pattern.
It is recommended to usescan(ScanOptions)
to iterate over the keyspace askeys(Publisher)
is a non-interruptible and expensive Redis operation.mDel
(List<ByteBuffer> keys) Delete multiple keys one in one batch.mDel
(Publisher<List<ByteBuffer>> keys) Delete multiple keys in batches.move
(ByteBuffer key, int database) Move givenkey
to database withindex
.move
(Publisher<ReactiveKeyCommands.MoveCommand> commands) Move keys one-by-one between databases.mUnlink
(List<ByteBuffer> keys) Unlink thekeys
from the keyspace.mUnlink
(Publisher<List<ByteBuffer>> keys) Unlink thekeys
from the keyspace.persist
(ByteBuffer key) Remove the expiration from givenkey
.persist
(Publisher<ReactiveRedisConnection.KeyCommand> commands) Remove one-by-one the expiration from givenkey
.pExpire
(ByteBuffer key, Duration timeout) Set time to live for givenkey
in milliseconds.pExpire
(Publisher<ReactiveKeyCommands.ExpireCommand> commands) Expire keys one by one.pExpireAt
(ByteBuffer key, Instant expireAt) Set the expiration for givenkey
as a UNIX timestamp.Set one-by-one the expiration for givenkey
as a UNIX timestamp in milliseconds.pTtl
(ByteBuffer key) Get the time to live forkey
in milliseconds.pTtl
(Publisher<ReactiveRedisConnection.KeyCommand> commands) Get one-by-one the time to live for keys.Return a random key from the keyspace.refcount
(ByteBuffer key) Get the number of references of the value associated with the specifiedkey
.rename
(ByteBuffer oldKey, ByteBuffer newKey) Rename key oldKey to newKey.rename
(Publisher<ReactiveKeyCommands.RenameCommand> command) Rename key oldKey to newKey.renameNX
(ByteBuffer key, ByteBuffer newKey) Rename key oldKey to newKey only if newKey does not exist.Rename key oldKey to newKey only if newKey does not exist.default Flux<ByteBuffer>
scan()
Use aFlux
to iterate over keys.default Flux<ByteBuffer>
scan
(KeyScanOptions options) Use aFlux
to iterate over keys.scan
(ScanOptions options) Use aFlux
to iterate over keys.touch
(Collection<ByteBuffer> keys) Alter the last access time of givenkey(s)
.touch
(Publisher<Collection<ByteBuffer>> keys) Alter the last access time of givenkey(s)
.ttl
(ByteBuffer key) Get the time to live forkey
in seconds.ttl
(Publisher<ReactiveRedisConnection.KeyCommand> commands) Get one-by-one the time to live for keys.type
(ByteBuffer key) Determine the type stored at key.Determine the type stored at key.unlink
(ByteBuffer key) Unlink thekey
from the keyspace.Unlink thekey
from the keyspace.
-
Method Details
-
copy
Copy givenkey
to a targetkey
.- Parameters:
sourceKey
- must not be null.targetKey
- must not be null.replace
- whether to replace existing keys.- Returns:
- Since:
- 2.6
- See Also:
-
copy
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.CopyCommand>> copy(Publisher<ReactiveKeyCommands.CopyCommand> commands) Copy keys one-by-one.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.BooleanResponse
holding the key to move along with the copy result.- Since:
- 2.6
- See Also:
-
exists
Determine if given key exists.- Parameters:
key
- must not be null.- Returns:
- See Also:
-
exists
Determine the number of given keys that exist.- Parameters:
keys
- must not be null or empty.- Returns:
Mono
emitting the number of existing keys.- Since:
- 3.5
- See Also:
-
exists
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveRedisConnection.KeyCommand>> exists(Publisher<ReactiveRedisConnection.KeyCommand> keys) Determine if given key exists.- Parameters:
keys
- must not be null.- Returns:
- See Also:
-
type
Determine the type stored at key.- Parameters:
key
- must not be null.- Returns:
- See Also:
-
type
Flux<ReactiveRedisConnection.CommandResponse<ReactiveRedisConnection.KeyCommand,DataType>> type(Publisher<ReactiveRedisConnection.KeyCommand> keys) Determine the type stored at key.- Parameters:
keys
- must not be null.- Returns:
- See Also:
-
touch
Alter the last access time of givenkey(s)
.- Parameters:
keys
- must not be null.- Returns:
Mono
emitting the number of keys touched.- Since:
- 2.1
- See Also:
-
touch
Flux<ReactiveRedisConnection.NumericResponse<Collection<ByteBuffer>,Long>> touch(Publisher<Collection<ByteBuffer>> keys) Alter the last access time of givenkey(s)
.- Parameters:
keys
- must not be null.- Returns:
- Since:
- 2.1
- See Also:
-
keys
Find all keys matching the given pattern.
It is recommended to usescan(ScanOptions)
to iterate over the keyspace askeys(ByteBuffer)
is a non-interruptible and expensive Redis operation.- Parameters:
pattern
- must not be null.- Returns:
- See Also:
-
keys
Flux<ReactiveRedisConnection.MultiValueResponse<ByteBuffer,ByteBuffer>> keys(Publisher<ByteBuffer> patterns) Find all keys matching the given pattern.
It is recommended to usescan(ScanOptions)
to iterate over the keyspace askeys(Publisher)
is a non-interruptible and expensive Redis operation.- Parameters:
patterns
- must not be null.- Returns:
- See Also:
-
scan
Use aFlux
to iterate over keys. The resultingFlux
acts as a cursor and issuesSCAN
commands itself as long as the subscriber signals demand.- Returns:
- never null.
- Since:
- 2.1
- See Also:
-
scan
Use aFlux
to iterate over keys. The resultingFlux
acts as a cursor and issuesSCAN
commands itself as long as the subscriber signals demand.- Parameters:
options
- must not be null.- Returns:
- the
Flux
emittingkeys
one by one. - Throws:
IllegalArgumentException
- when options is null.- Since:
- 2.6
- See Also:
-
scan
Use aFlux
to iterate over keys. The resultingFlux
acts as a cursor and issuesSCAN
commands itself as long as the subscriber signals demand.- Parameters:
options
- must not be null.- Returns:
- the
Flux
emittingkeys
one by one. - Throws:
IllegalArgumentException
- when options is null.- Since:
- 2.1
- See Also:
-
randomKey
Mono<ByteBuffer> randomKey()Return a random key from the keyspace.- Returns:
- See Also:
-
rename
Rename key oldKey to newKey.- Parameters:
oldKey
- must not be null.newKey
- must not be null.- Returns:
- See Also:
-
rename
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.RenameCommand>> rename(Publisher<ReactiveKeyCommands.RenameCommand> command) Rename key oldKey to newKey.- Parameters:
command
- must not be null.- Returns:
- See Also:
-
renameNX
Rename key oldKey to newKey only if newKey does not exist.- Parameters:
key
- must not be null.newKey
- must not be null.- Returns:
- See Also:
-
renameNX
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.RenameCommand>> renameNX(Publisher<ReactiveKeyCommands.RenameCommand> command) Rename key oldKey to newKey only if newKey does not exist.- Parameters:
command
- must not be null.- Returns:
- See Also:
-
del
Delete key.- Parameters:
key
- must not be null.- Returns:
- See Also:
-
del
Flux<ReactiveRedisConnection.NumericResponse<ReactiveRedisConnection.KeyCommand,Long>> del(Publisher<ReactiveRedisConnection.KeyCommand> keys) Delete keys one by one.- Parameters:
keys
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.NumericResponse
holding the key removed along with the deletion result.- See Also:
-
mDel
Delete multiple keys one in one batch.- Parameters:
keys
- must not be null.- Returns:
- See Also:
-
mDel
Flux<ReactiveRedisConnection.NumericResponse<List<ByteBuffer>,Long>> mDel(Publisher<List<ByteBuffer>> keys) Delete multiple keys in batches.- Parameters:
keys
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.NumericResponse
holding the keys removed along with the deletion result.- See Also:
-
unlink
Unlink thekey
from the keyspace. Unlike withdel(ByteBuffer)
the actual memory reclaiming here happens asynchronously.- Parameters:
key
- must not be null.- Returns:
- Since:
- 2.1
- See Also:
-
unlink
Flux<ReactiveRedisConnection.NumericResponse<ReactiveRedisConnection.KeyCommand,Long>> unlink(Publisher<ReactiveRedisConnection.KeyCommand> keys) Unlink thekey
from the keyspace. Unlike withdel(ByteBuffer)
the actual memory reclaiming here happens asynchronously.- Parameters:
keys
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.NumericResponse
holding the key removed along with the unlink result.- Since:
- 2.1
- See Also:
-
mUnlink
Unlink thekeys
from the keyspace. Unlike withmDel(List)
the actual memory reclaiming here happens asynchronously.- Parameters:
keys
- must not be null.- Returns:
- Since:
- 2.1
- See Also:
-
mUnlink
Flux<ReactiveRedisConnection.NumericResponse<List<ByteBuffer>,Long>> mUnlink(Publisher<List<ByteBuffer>> keys) Unlink thekeys
from the keyspace. Unlike withmDel(Publisher)
the actual memory reclaiming here happens asynchronously.- Parameters:
keys
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.NumericResponse
holding the key removed along with the deletion result.- Since:
- 2.1
- See Also:
-
applyExpiration
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.ExpireCommand>> applyExpiration(Publisher<ReactiveKeyCommands.ExpireCommand> commands) - Parameters:
commands
- must not be null.- Returns:
- a
Flux
emitting the expiration results one by one, true if the timeout was set or false if the timeout was not set; for example, the key doesn't exist, or the operation was skipped because of the provided arguments. - Since:
- 3.5
- See Also:
-
expire
Set time to live for givenkey
in seconds.- Parameters:
key
- must not be null.timeout
- must not be null.- Returns:
- See Also:
-
expire
default Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.ExpireCommand>> expire(Publisher<ReactiveKeyCommands.ExpireCommand> commands) Expire keys one by one.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.BooleanResponse
holding the key removed along with the expiration result.- See Also:
-
pExpire
Set time to live for givenkey
in milliseconds.- Parameters:
key
- must not be null.timeout
- must not be null.- Returns:
- See Also:
-
pExpire
default Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.ExpireCommand>> pExpire(Publisher<ReactiveKeyCommands.ExpireCommand> commands) Expire keys one by one.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.BooleanResponse
holding the key removed along with the expiration result.- See Also:
-
expireAt
Set the expiration for givenkey
as a UNIX timestamp.- Parameters:
key
- must not be null.expireAt
- must not be null.- Returns:
- See Also:
-
expireAt
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.ExpireAtCommand>> expireAt(Publisher<ReactiveKeyCommands.ExpireAtCommand> commands) Set one-by-one the expiration for givenkey
as a UNIX timestamp.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.BooleanResponse
holding the key removed along with the expiration result.- See Also:
-
pExpireAt
Set the expiration for givenkey
as a UNIX timestamp.- Parameters:
key
- must not be null.expireAt
- must not be null.- Returns:
- See Also:
-
pExpireAt
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.ExpireAtCommand>> pExpireAt(Publisher<ReactiveKeyCommands.ExpireAtCommand> commands) Set one-by-one the expiration for givenkey
as a UNIX timestamp in milliseconds.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.BooleanResponse
holding the key removed along with the expiration result.- See Also:
-
persist
Remove the expiration from givenkey
.- Parameters:
key
- must not be null.- Returns:
- See Also:
-
persist
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveRedisConnection.KeyCommand>> persist(Publisher<ReactiveRedisConnection.KeyCommand> commands) Remove one-by-one the expiration from givenkey
.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.BooleanResponse
holding the key persisted along with the persist result.- See Also:
-
ttl
Get the time to live forkey
in seconds.- Parameters:
key
- must not be null.- Returns:
- See Also:
-
ttl
Flux<ReactiveRedisConnection.NumericResponse<ReactiveRedisConnection.KeyCommand,Long>> ttl(Publisher<ReactiveRedisConnection.KeyCommand> commands) Get one-by-one the time to live for keys.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.NumericResponse
holding the key along with the time to live result.- See Also:
-
pTtl
Get the time to live forkey
in milliseconds.- Parameters:
key
- must not be null.- Returns:
- See Also:
-
pTtl
Flux<ReactiveRedisConnection.NumericResponse<ReactiveRedisConnection.KeyCommand,Long>> pTtl(Publisher<ReactiveRedisConnection.KeyCommand> commands) Get one-by-one the time to live for keys.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.NumericResponse
holding the key along with the time to live result.- See Also:
-
move
Move givenkey
to database withindex
.- Parameters:
key
- must not be null.- Returns:
- See Also:
-
move
Flux<ReactiveRedisConnection.BooleanResponse<ReactiveKeyCommands.MoveCommand>> move(Publisher<ReactiveKeyCommands.MoveCommand> commands) Move keys one-by-one between databases.- Parameters:
commands
- must not be null.- Returns:
Flux
ofReactiveRedisConnection.BooleanResponse
holding the key to move along with the move result.- See Also:
-
encodingOf
Get the type of internal representation used for storing the value at the givenkey
.- Parameters:
key
- must not be null.- Returns:
- the
Mono
emittingValueEncoding
. - Throws:
IllegalArgumentException
- ifkey
is null.- Since:
- 2.1
- See Also:
-
idletime
Get theDuration
since the object stored at the givenkey
is idle.- Parameters:
key
- must not be null.- Returns:
- the
Mono
emitting the idletime of the key ofMono.empty()
if the key does not exist. - Throws:
IllegalArgumentException
- ifkey
is null.- Since:
- 2.1
- See Also:
-
refcount
Get the number of references of the value associated with the specifiedkey
.- Parameters:
key
- must not be null.- Returns:
Mono.empty()
if key does not exist.- Throws:
IllegalArgumentException
- ifkey
is null.- Since:
- 2.1
- See Also:
-