K
- Key type.V
- Value type.public interface RedisKeyCommands<K,V>
Modifier and Type | Method and Description |
---|---|
Boolean |
copy(K source,
K destination)
Copy the value stored at the source key to the destination key.
|
Boolean |
copy(K source,
K destination,
CopyArgs copyArgs)
Copy the value stored at the source key to the destination key.
|
Long |
del(K... keys)
Delete one or more keys.
|
byte[] |
dump(K key)
Return a serialized version of the value stored at the specified key.
|
Long |
exists(K... keys)
Determine how many keys exist.
|
Boolean |
expire(K key,
Duration seconds)
Set a key's time to live in seconds.
|
Boolean |
expire(K key,
Duration seconds,
ExpireArgs expireArgs)
Set a key's time to live in seconds.
|
Boolean |
expire(K key,
long seconds)
Set a key's time to live in seconds.
|
Boolean |
expire(K key,
long seconds,
ExpireArgs expireArgs)
Set a key's time to live in seconds.
|
Boolean |
expireat(K key,
Date timestamp)
Set the expiration for a key as a UNIX timestamp.
|
Boolean |
expireat(K key,
Date timestamp,
ExpireArgs expireArgs)
Set the expiration for a key as a UNIX timestamp.
|
Boolean |
expireat(K key,
Instant timestamp)
Set the expiration for a key as a UNIX timestamp.
|
Boolean |
expireat(K key,
Instant timestamp,
ExpireArgs expireArgs)
Set the expiration for a key as a UNIX timestamp.
|
Boolean |
expireat(K key,
long timestamp)
Set the expiration for a key as a UNIX timestamp.
|
Boolean |
expireat(K key,
long timestamp,
ExpireArgs expireArgs)
Set the expiration for a key as a UNIX timestamp.
|
Long |
expiretime(K key)
Get the time to live for a key in as unix timestamp in seconds.
|
List<K> |
keys(K pattern)
Find all keys matching the given pattern.
|
Long |
keys(KeyStreamingChannel<K> channel,
K pattern)
Find all keys matching the given pattern.
|
String |
migrate(String host,
int port,
int db,
long timeout,
MigrateArgs<K> migrateArgs)
Atomically transfer one or more keys from a Redis instance to another one.
|
String |
migrate(String host,
int port,
K key,
int db,
long timeout)
Atomically transfer a key from a Redis instance to another one.
|
Boolean |
move(K key,
int db)
Move a key to another database.
|
String |
objectEncoding(K key)
Returns the kind of internal representation used in order to store the value associated with the
key . |
Long |
objectFreq(K key)
Returns the logarithmic access frequency counter of the object stored at the specified
key . |
Long |
objectIdletime(K key)
Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write
operations).
|
Long |
objectRefcount(K key)
Returns the number of references of the value associated with the specified key.
|
Boolean |
persist(K key)
Remove the expiration from a key.
|
Boolean |
pexpire(K key,
Duration milliseconds)
Set a key's time to live in milliseconds.
|
Boolean |
pexpire(K key,
Duration milliseconds,
ExpireArgs expireArgs)
Set a key's time to live in milliseconds.
|
Boolean |
pexpire(K key,
long milliseconds)
Set a key's time to live in milliseconds.
|
Boolean |
pexpire(K key,
long milliseconds,
ExpireArgs expireArgs)
Set a key's time to live in milliseconds.
|
Boolean |
pexpireat(K key,
Date timestamp)
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
|
Boolean |
pexpireat(K key,
Date timestamp,
ExpireArgs expireArgs)
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
|
Boolean |
pexpireat(K key,
Instant timestamp)
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
|
Boolean |
pexpireat(K key,
Instant timestamp,
ExpireArgs expireArgs)
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
|
Boolean |
pexpireat(K key,
long timestamp)
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
|
Boolean |
pexpireat(K key,
long timestamp,
ExpireArgs expireArgs)
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
|
Long |
pexpiretime(K key)
Get the time to live for a key in as unix timestamp in milliseconds.
|
Long |
pttl(K key)
Get the time to live for a key in milliseconds.
|
K |
randomkey()
Return a random key from the keyspace.
|
String |
rename(K key,
K newKey)
Rename a key.
|
Boolean |
renamenx(K key,
K newKey)
Rename a key, only if the new key does not exist.
|
String |
restore(K key,
byte[] value,
RestoreArgs args)
Create a key using the provided serialized value, previously obtained using DUMP.
|
String |
restore(K key,
long ttl,
byte[] value)
Create a key using the provided serialized value, previously obtained using DUMP.
|
KeyScanCursor<K> |
scan()
Incrementally iterate the keys space.
|
StreamScanCursor |
scan(KeyStreamingChannel<K> channel)
Incrementally iterate the keys space.
|
StreamScanCursor |
scan(KeyStreamingChannel<K> channel,
ScanArgs scanArgs)
Incrementally iterate the keys space.
|
StreamScanCursor |
scan(KeyStreamingChannel<K> channel,
ScanCursor scanCursor)
Incrementally iterate the keys space.
|
StreamScanCursor |
scan(KeyStreamingChannel<K> channel,
ScanCursor scanCursor,
ScanArgs scanArgs)
Incrementally iterate the keys space.
|
KeyScanCursor<K> |
scan(ScanArgs scanArgs)
Incrementally iterate the keys space.
|
KeyScanCursor<K> |
scan(ScanCursor scanCursor)
Incrementally iterate the keys space.
|
KeyScanCursor<K> |
scan(ScanCursor scanCursor,
ScanArgs scanArgs)
Incrementally iterate the keys space.
|
List<V> |
sort(K key)
Sort the elements in a list, set or sorted set.
|
List<V> |
sort(K key,
SortArgs sortArgs)
Sort the elements in a list, set or sorted set.
|
Long |
sort(ValueStreamingChannel<V> channel,
K key)
Sort the elements in a list, set or sorted set.
|
Long |
sort(ValueStreamingChannel<V> channel,
K key,
SortArgs sortArgs)
Sort the elements in a list, set or sorted set.
|
List<V> |
sortReadOnly(K key)
Sort the elements in a list, set or sorted set.
|
List<V> |
sortReadOnly(K key,
SortArgs sortArgs)
Sort the elements in a list, set or sorted set.
|
Long |
sortReadOnly(ValueStreamingChannel<V> channel,
K key)
Sort the elements in a list, set or sorted set.
|
Long |
sortReadOnly(ValueStreamingChannel<V> channel,
K key,
SortArgs sortArgs)
Sort the elements in a list, set or sorted set.
|
Long |
sortStore(K key,
SortArgs sortArgs,
K destination)
Sort the elements in a list, set or sorted set.
|
Long |
touch(K... keys)
Touch one or more keys.
|
Long |
ttl(K key)
Get the time to live for a key.
|
String |
type(K key)
Determine the type stored at key.
|
Long |
unlink(K... keys)
Unlink one or more keys (non blocking DEL).
|
Boolean copy(K source, K destination)
source
- the source.destination
- the destination.true
if source was copied. false
if source was not copied.Boolean copy(K source, K destination, CopyArgs copyArgs)
source
- the source.destination
- the destination.copyArgs
- the copyArgs.true
if source was copied. false
if source was not copied.Long del(K... keys)
keys
- the keys.Long unlink(K... keys)
keys
- the keys.byte[] dump(K key)
key
- the key.Long exists(K... keys)
keys
- the keys.Boolean expire(K key, long seconds)
key
- the key.seconds
- the seconds type: long.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set.Boolean expire(K key, long seconds, ExpireArgs expireArgs)
key
- the key.seconds
- the seconds type: long.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set.Boolean expire(K key, Duration seconds)
key
- the key.seconds
- the seconds.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set.Boolean expire(K key, Duration seconds, ExpireArgs expireArgs)
key
- the key.seconds
- the seconds.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set.Boolean expireat(K key, long timestamp)
key
- the key.timestamp
- the timestamp type: posix time.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean expireat(K key, long timestamp, ExpireArgs expireArgs)
key
- the key.timestamp
- the timestamp type: posix time.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean expireat(K key, Date timestamp)
key
- the key.timestamp
- the timestamp type: posix time.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean expireat(K key, Date timestamp, ExpireArgs expireArgs)
key
- the key.timestamp
- the timestamp type: posix time.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean expireat(K key, Instant timestamp)
key
- the key.timestamp
- the timestamp type: posix time.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean expireat(K key, Instant timestamp, ExpireArgs expireArgs)
key
- the key.timestamp
- the timestamp type: posix time.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Long expiretime(K key)
key
- the key.-1
if
the key exists but has no associated expiration time. The command returns -2
if the key does not exist.List<K> keys(K pattern)
pattern
- the pattern type: patternkey (pattern).pattern
.Long keys(KeyStreamingChannel<K> channel, K pattern)
channel
- the channel.pattern
- the pattern.pattern
.String migrate(String host, int port, K key, int db, long timeout)
host
- the host.port
- the port.key
- the key.db
- the database.timeout
- the timeout in milliseconds.String migrate(String host, int port, int db, long timeout, MigrateArgs<K> migrateArgs)
host
- the host.port
- the port.db
- the database.timeout
- the timeout in milliseconds.migrateArgs
- migrate args that allow to configure further options.Boolean move(K key, int db)
key
- the key.db
- the db type: long.String objectEncoding(K key)
key
.key
- the key.Long objectFreq(K key)
key
.key
- the key.Long objectIdletime(K key)
key
- the key.Long objectRefcount(K key)
key
- the key.Boolean persist(K key)
key
- the key.true
if the timeout was removed. false
if key
does not exist or does not have an
associated timeout.Boolean pexpire(K key, long milliseconds)
key
- the key.milliseconds
- the milliseconds type: long.true
if the timeout was set. false
if key
does not exist or
the timeout could not be set.Boolean pexpire(K key, long milliseconds, ExpireArgs expireArgs)
key
- the key.milliseconds
- the milliseconds type: long.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not exist or
the timeout could not be set.Boolean pexpire(K key, Duration milliseconds)
key
- the key.milliseconds
- the milliseconds.true
if the timeout was set. false
if key
does not exist or
the timeout could not be set.Boolean pexpire(K key, Duration milliseconds, ExpireArgs expireArgs)
key
- the key.milliseconds
- the milliseconds.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not exist or
the timeout could not be set.Boolean pexpireat(K key, long timestamp)
key
- the key.timestamp
- the milliseconds-timestamp type: posix time.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean pexpireat(K key, long timestamp, ExpireArgs expireArgs)
key
- the key.timestamp
- the milliseconds-timestamp type: posix time.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean pexpireat(K key, Date timestamp)
key
- the key.timestamp
- the milliseconds-timestamp type: posix time.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean pexpireat(K key, Date timestamp, ExpireArgs expireArgs)
key
- the key.timestamp
- the milliseconds-timestamp type: posix time.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean pexpireat(K key, Instant timestamp)
key
- the key.timestamp
- the milliseconds-timestamp type: posix time.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Boolean pexpireat(K key, Instant timestamp, ExpireArgs expireArgs)
key
- the key.timestamp
- the milliseconds-timestamp type: posix time.expireArgs
- the expiry arguments.true
if the timeout was set. false
if key
does not
exist or the timeout could not be set (see: EXPIRE
).Long pexpiretime(K key)
key
- the key.-1
if the key exists but has no associated expiration time. The command returns -2
if the key
does not exist.Long pttl(K key)
key
- the key.-1
if the key exists but has no associated expiration time. The command returns -2
if the key
does not exist.K randomkey()
null
when the database is empty.String rename(K key, K newKey)
key
- the key.newKey
- the newkey type: key.Boolean renamenx(K key, K newKey)
key
- the key.newKey
- the newkey type: key.true
if key
was renamed to newkey
. false
if newkey
already exists.String restore(K key, long ttl, byte[] value)
key
- the key.ttl
- the ttl type: long.value
- the serialized-value type: string.String restore(K key, byte[] value, RestoreArgs args)
key
- the key.value
- the serialized-value type: string.args
- the RestoreArgs
, must not be null
.List<V> sort(K key)
key
- the key.Long sort(ValueStreamingChannel<V> channel, K key)
channel
- streaming channel that receives a call for every value.key
- the key.List<V> sort(K key, SortArgs sortArgs)
key
- the key.sortArgs
- sort arguments.Long sort(ValueStreamingChannel<V> channel, K key, SortArgs sortArgs)
channel
- streaming channel that receives a call for every value.key
- the key.sortArgs
- sort arguments.List<V> sortReadOnly(K key)
key
- the key.Long sortReadOnly(ValueStreamingChannel<V> channel, K key)
channel
- streaming channel that receives a call for every value.key
- the key.List<V> sortReadOnly(K key, SortArgs sortArgs)
key
- the key.sortArgs
- sort arguments.Long sortReadOnly(ValueStreamingChannel<V> channel, K key, SortArgs sortArgs)
channel
- streaming channel that receives a call for every value.key
- the key.sortArgs
- sort arguments.Long sortStore(K key, SortArgs sortArgs, K destination)
key
- the key.sortArgs
- sort arguments.destination
- the destination key to store sort results.Long touch(K... keys)
keys
- the keys.Long ttl(K key)
key
- the key.-1
if the key exists but has no associated expiration time. The command returns -2
if the key
does not exist.String type(K key)
key
- the key.key
, or none
when key
does not exist.KeyScanCursor<K> scan()
KeyScanCursor<K> scan(ScanArgs scanArgs)
KeyScanArgs
to specify SCAN
-specific arguments.scanArgs
- scan arguments.KeyScanArgs
KeyScanCursor<K> scan(ScanCursor scanCursor, ScanArgs scanArgs)
KeyScanArgs
to specify SCAN
-specific arguments.scanCursor
- cursor to resume from a previous scan, must not be null
.scanArgs
- scan arguments.KeyScanArgs
KeyScanCursor<K> scan(ScanCursor scanCursor)
scanCursor
- cursor to resume from a previous scan, must not be null
.StreamScanCursor scan(KeyStreamingChannel<K> channel)
channel
- streaming channel that receives a call for every key.StreamScanCursor scan(KeyStreamingChannel<K> channel, ScanArgs scanArgs)
KeyScanArgs
to specify SCAN
-specific arguments.channel
- streaming channel that receives a call for every key.scanArgs
- scan arguments.KeyScanArgs
StreamScanCursor scan(KeyStreamingChannel<K> channel, ScanCursor scanCursor, ScanArgs scanArgs)
KeyScanArgs
to specify SCAN
-specific arguments.channel
- streaming channel that receives a call for every key.scanCursor
- cursor to resume from a previous scan, must not be null
.scanArgs
- scan arguments.KeyScanArgs
StreamScanCursor scan(KeyStreamingChannel<K> channel, ScanCursor scanCursor)
channel
- streaming channel that receives a call for every key.scanCursor
- cursor to resume from a previous scan, must not be null
.Copyright © 2025 lettuce.io. All rights reserved.