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 classMOVEcommand parameters.static classEXPIREAT/PEXPIREATcommand parameters.static classEXPIRE/PEXPIREcommand parameters.static classMOVEcommand parameters.static classRENAMEcommand parameters. -
Method Summary
Modifier and TypeMethodDescriptioncopy(ByteBuffer sourceKey, ByteBuffer targetKey, boolean replace) Copy givenkeyto 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 givenkeyin seconds.expire(Publisher<ReactiveKeyCommands.ExpireCommand> commands) Expire keys one by one.expireAt(ByteBuffer key, Instant expireAt) Set the expiration for givenkeyas a UNIX timestamp.expireAt(Publisher<ReactiveKeyCommands.ExpireAtCommand> commands) Set one-by-one the expiration for givenkeyas a UNIX timestamp.idletime(ByteBuffer key) Get theDurationsince the object stored at the givenkeyis idle.default Mono<List<ByteBuffer>>keys(ByteBuffer pattern) Retrieve all keys matching the given pattern viaKEYScommand.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 givenkeyto database withindex.move(Publisher<ReactiveKeyCommands.MoveCommand> commands) Move keys one-by-one between databases.mUnlink(List<ByteBuffer> keys) Unlink thekeysfrom the keyspace.mUnlink(Publisher<List<ByteBuffer>> keys) Unlink thekeysfrom 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 givenkeyin milliseconds.pExpire(Publisher<ReactiveKeyCommands.ExpireCommand> commands) Expire keys one by one.pExpireAt(ByteBuffer key, Instant expireAt) Set the expiration for givenkeyas a UNIX timestamp.Set one-by-one the expiration for givenkeyas a UNIX timestamp in milliseconds.pTtl(ByteBuffer key) Get the time to live forkeyin 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 aFluxto iterate over keys.default Flux<ByteBuffer>scan(KeyScanOptions options) Use aFluxto iterate over keys.scan(ScanOptions options) Use aFluxto 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 forkeyin 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 thekeyfrom the keyspace.Unlink thekeyfrom the keyspace.
-
Method Details
-
copy
Copy givenkeyto 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:
FluxofReactiveRedisConnection.BooleanResponseholding 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:
Monoemitting 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:
Monoemitting 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
Retrieve all keys matching the given pattern viaKEYScommand.IMPORTANT: This command is non-interruptible and scans the entire keyspace which may cause performance issues. Consider
scan(ScanOptions)for large datasets.- 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 aFluxto iterate over keys. The resultingFluxacts as a cursor and issuesSCANcommands itself as long as the subscriber signals demand.- Returns:
- never null.
- Since:
- 2.1
- See Also:
-
scan
Use aFluxto iterate over keys. The resultingFluxacts as a cursor and issuesSCANcommands itself as long as the subscriber signals demand.- Parameters:
options- must not be null.- Returns:
- the
Fluxemittingkeysone by one. - Throws:
IllegalArgumentException- when options is null.- Since:
- 2.6
- See Also:
-
scan
Use aFluxto iterate over keys. The resultingFluxacts as a cursor and issuesSCANcommands itself as long as the subscriber signals demand.- Parameters:
options- must not be null.- Returns:
- the
Fluxemittingkeysone 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:
FluxofReactiveRedisConnection.NumericResponseholding 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:
FluxofReactiveRedisConnection.NumericResponseholding the keys removed along with the deletion result.- See Also:
-
unlink
Unlink thekeyfrom 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 thekeyfrom the keyspace. Unlike withdel(ByteBuffer)the actual memory reclaiming here happens asynchronously.- Parameters:
keys- must not be null.- Returns:
FluxofReactiveRedisConnection.NumericResponseholding the key removed along with the unlink result.- Since:
- 2.1
- See Also:
-
mUnlink
Unlink thekeysfrom 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 thekeysfrom the keyspace. Unlike withmDel(Publisher)the actual memory reclaiming here happens asynchronously.- Parameters:
keys- must not be null.- Returns:
FluxofReactiveRedisConnection.NumericResponseholding 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
Fluxemitting 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 givenkeyin 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:
FluxofReactiveRedisConnection.BooleanResponseholding the key removed along with the expiration result.- See Also:
-
pExpire
Set time to live for givenkeyin 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:
FluxofReactiveRedisConnection.BooleanResponseholding the key removed along with the expiration result.- See Also:
-
expireAt
Set the expiration for givenkeyas 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 givenkeyas a UNIX timestamp.- Parameters:
commands- must not be null.- Returns:
FluxofReactiveRedisConnection.BooleanResponseholding the key removed along with the expiration result.- See Also:
-
pExpireAt
Set the expiration for givenkeyas 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 givenkeyas a UNIX timestamp in milliseconds.- Parameters:
commands- must not be null.- Returns:
FluxofReactiveRedisConnection.BooleanResponseholding 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:
FluxofReactiveRedisConnection.BooleanResponseholding the key persisted along with the persist result.- See Also:
-
ttl
Get the time to live forkeyin 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:
FluxofReactiveRedisConnection.NumericResponseholding the key along with the time to live result.- See Also:
-
pTtl
Get the time to live forkeyin 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:
FluxofReactiveRedisConnection.NumericResponseholding the key along with the time to live result.- See Also:
-
move
Move givenkeyto 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:
FluxofReactiveRedisConnection.BooleanResponseholding 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
MonoemittingValueEncoding. - Throws:
IllegalArgumentException- ifkeyis null.- Since:
- 2.1
- See Also:
-
idletime
Get theDurationsince the object stored at the givenkeyis idle.- Parameters:
key- must not be null.- Returns:
- the
Monoemitting the idletime of the key ofMono.empty()if the key does not exist. - Throws:
IllegalArgumentException- ifkeyis 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- ifkeyis null.- Since:
- 2.1
- See Also:
-