- Type Parameters:
K- Key type.V- Value type.
- All Known Subinterfaces:
RedisAdvancedClusterCommands<K,V>,RedisClusterCommands<K,V>,RedisClusterPubSubCommands<K,V>,RedisCommands<K,V>,RedisPubSubCommands<K,V>
public interface RedisKeyCommands<K,V>
Synchronous executed commands for Keys (Key manipulation/querying).
- Since:
- 4.0
- Author:
- Mark Paluch
- Generated class:
- by io.lettuce.apigenerator.CreateSyncApi
-
Method Summary
Modifier and Type Method Description Booleancopy(K source, K destination)Copy the value stored at the source key to the destination key.Booleancopy(K source, K destination, CopyArgs copyArgs)Copy the value stored at the source key to the destination key.Longdel(K... keys)Delete one or more keys.byte[]dump(K key)Return a serialized version of the value stored at the specified key.Longexists(K... keys)Determine how many keys exist.Booleanexpire(K key, long seconds)Set a key's time to live in seconds.Booleanexpire(K key, Duration seconds)Set a key's time to live in seconds.Booleanexpireat(K key, long timestamp)Set the expiration for a key as a UNIX timestamp.Booleanexpireat(K key, Instant timestamp)Set the expiration for a key as a UNIX timestamp.Booleanexpireat(K key, Date timestamp)Set the expiration for a key as a UNIX timestamp.Longkeys(KeyStreamingChannel<K> channel, K pattern)Find all keys matching the given pattern.List<K>keys(K pattern)Find all keys matching the given pattern.Stringmigrate(String host, int port, int db, long timeout, MigrateArgs<K> migrateArgs)Atomically transfer one or more keys from a Redis instance to another one.Stringmigrate(String host, int port, K key, int db, long timeout)Atomically transfer a key from a Redis instance to another one.Booleanmove(K key, int db)Move a key to another database.StringobjectEncoding(K key)Returns the kind of internal representation used in order to store the value associated with thekey.LongobjectFreq(K key)Returns the logarithmic access frequency counter of the object stored at the specifiedkey.LongobjectIdletime(K key)Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations).LongobjectRefcount(K key)Returns the number of references of the value associated with the specified key.Booleanpersist(K key)Remove the expiration from a key.Booleanpexpire(K key, long milliseconds)Set a key's time to live in milliseconds.Booleanpexpire(K key, Duration milliseconds)Set a key's time to live in milliseconds.Booleanpexpireat(K key, long timestamp)Set the expiration for a key as a UNIX timestamp specified in milliseconds.Booleanpexpireat(K key, Instant timestamp)Set the expiration for a key as a UNIX timestamp specified in milliseconds.Booleanpexpireat(K key, Date timestamp)Set the expiration for a key as a UNIX timestamp specified in milliseconds.Longpttl(K key)Get the time to live for a key in milliseconds.Krandomkey()Return a random key from the keyspace.Stringrename(K key, K newKey)Rename a key.Booleanrenamenx(K key, K newKey)Rename a key, only if the new key does not exist.Stringrestore(K key, byte[] value, RestoreArgs args)Create a key using the provided serialized value, previously obtained using DUMP.Stringrestore(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.StreamScanCursorscan(KeyStreamingChannel<K> channel)Incrementally iterate the keys space.StreamScanCursorscan(KeyStreamingChannel<K> channel, ScanArgs scanArgs)Incrementally iterate the keys space.StreamScanCursorscan(KeyStreamingChannel<K> channel, ScanCursor scanCursor)Incrementally iterate the keys space.StreamScanCursorscan(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.Longsort(ValueStreamingChannel<V> channel, K key)Sort the elements in a list, set or sorted set.Longsort(ValueStreamingChannel<V> channel, K key, SortArgs sortArgs)Sort the elements in a list, set or sorted set.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.LongsortStore(K key, SortArgs sortArgs, K destination)Sort the elements in a list, set or sorted set.Longtouch(K... keys)Touch one or more keys.Longttl(K key)Get the time to live for a key.Stringtype(K key)Determine the type stored at key.Longunlink(K... keys)Unlink one or more keys (non blocking DEL).
-
Method Details
-
copy
Copy the value stored at the source key to the destination key.- Parameters:
source- the source.destination- the destination.- Returns:
- Boolean integer-reply specifically:
trueif source was copied.falseif source was not copied. - Since:
- 6.1
-
copy
Copy the value stored at the source key to the destination key.- Parameters:
source- the source.destination- the destination.copyArgs- the copyArgs.- Returns:
- Boolean integer-reply specifically:
trueif source was copied.falseif source was not copied. - Since:
- 6.1
-
del
Delete one or more keys.- Parameters:
keys- the keys.- Returns:
- Long integer-reply The number of keys that were removed.
-
unlink
Unlink one or more keys (non blocking DEL).- Parameters:
keys- the keys.- Returns:
- Long integer-reply The number of keys that were removed.
-
dump
Return a serialized version of the value stored at the specified key.- Parameters:
key- the key.- Returns:
- byte[] bulk-string-reply the serialized value.
-
exists
Determine how many keys exist.- Parameters:
keys- the keys.- Returns:
- Long integer-reply specifically: Number of existing keys.
-
expire
Set a key's time to live in seconds.- Parameters:
key- the key.seconds- the seconds type: long.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set.
-
expire
Set a key's time to live in seconds.- Parameters:
key- the key.seconds- the seconds.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set. - Since:
- 6.1
-
expireat
Set the expiration for a key as a UNIX timestamp.- Parameters:
key- the key.timestamp- the timestamp type: posix time.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set (see:EXPIRE).
-
expireat
Set the expiration for a key as a UNIX timestamp.- Parameters:
key- the key.timestamp- the timestamp type: posix time.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set (see:EXPIRE).
-
expireat
Set the expiration for a key as a UNIX timestamp.- Parameters:
key- the key.timestamp- the timestamp type: posix time.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set (see:EXPIRE). - Since:
- 6.1
-
keys
Find all keys matching the given pattern.- Parameters:
pattern- the pattern type: patternkey (pattern).- Returns:
- List<K> array-reply list of keys matching
pattern.
-
keys
Find all keys matching the given pattern.- Parameters:
channel- the channel.pattern- the pattern.- Returns:
- Long array-reply list of keys matching
pattern.
-
migrate
Atomically transfer a key from a Redis instance to another one.- Parameters:
host- the host.port- the port.key- the key.db- the database.timeout- the timeout in milliseconds.- Returns:
- String simple-string-reply The command returns OK on success.
-
migrate
Atomically transfer one or more keys from a Redis instance to another one.- Parameters:
host- the host.port- the port.db- the database.timeout- the timeout in milliseconds.migrateArgs- migrate args that allow to configure further options.- Returns:
- String simple-string-reply The command returns OK on success.
-
move
Move a key to another database.- Parameters:
key- the key.db- the db type: long.- Returns:
- Boolean integer-reply specifically:.
-
objectEncoding
Returns the kind of internal representation used in order to store the value associated with thekey.- Parameters:
key- the key.- Returns:
- String.
-
objectFreq
Returns the logarithmic access frequency counter of the object stored at the specifiedkey.- Parameters:
key- the key.- Returns:
- Long.
- Since:
- 6.1
-
objectIdletime
Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations).- Parameters:
key- the key.- Returns:
- number of seconds since the object stored at the specified key is idle.
-
objectRefcount
Returns the number of references of the value associated with the specified key.- Parameters:
key- the key.- Returns:
- Long.
-
persist
Remove the expiration from a key.- Parameters:
key- the key.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was removed.falseifkeydoes not exist or does not have an associated timeout.
-
pexpire
Set a key's time to live in milliseconds.- Parameters:
key- the key.milliseconds- the milliseconds type: long.- Returns:
- integer-reply, specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set.
-
pexpire
Set a key's time to live in milliseconds.- Parameters:
key- the key.milliseconds- the milliseconds.- Returns:
- integer-reply, specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set. - Since:
- 6.1
-
pexpireat
Set the expiration for a key as a UNIX timestamp specified in milliseconds.- Parameters:
key- the key.timestamp- the milliseconds-timestamp type: posix time.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set (see:EXPIRE).
-
pexpireat
Set the expiration for a key as a UNIX timestamp specified in milliseconds.- Parameters:
key- the key.timestamp- the milliseconds-timestamp type: posix time.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set (see:EXPIRE).
-
pexpireat
Set the expiration for a key as a UNIX timestamp specified in milliseconds.- Parameters:
key- the key.timestamp- the milliseconds-timestamp type: posix time.- Returns:
- Boolean integer-reply specifically:
trueif the timeout was set.falseifkeydoes not exist or the timeout could not be set (see:EXPIRE).
-
pttl
Get the time to live for a key in milliseconds.- Parameters:
key- the key.- Returns:
- Long integer-reply TTL in milliseconds, or a negative value in order to signal an error (see the description above).
-
randomkey
K randomkey()Return a random key from the keyspace.- Returns:
- K bulk-string-reply the random key, or
nullwhen the database is empty.
-
rename
Rename a key.- Parameters:
key- the key.newKey- the newkey type: key.- Returns:
- String simple-string-reply.
-
renamenx
Rename a key, only if the new key does not exist.- Parameters:
key- the key.newKey- the newkey type: key.- Returns:
- Boolean integer-reply specifically:
trueifkeywas renamed tonewkey.falseifnewkeyalready exists.
-
restore
Create a key using the provided serialized value, previously obtained using DUMP.- Parameters:
key- the key.ttl- the ttl type: long.value- the serialized-value type: string.- Returns:
- String simple-string-reply The command returns OK on success.
-
restore
Create a key using the provided serialized value, previously obtained using DUMP.- Parameters:
key- the key.value- the serialized-value type: string.args- theRestoreArgs, must not benull.- Returns:
- String simple-string-reply The command returns OK on success.
- Since:
- 5.1
-
sort
Sort the elements in a list, set or sorted set.- Parameters:
key- the key.- Returns:
- List<V> array-reply list of sorted elements.
-
sort
Sort the elements in a list, set or sorted set.- Parameters:
channel- streaming channel that receives a call for every value.key- the key.- Returns:
- Long number of values.
-
sort
Sort the elements in a list, set or sorted set.- Parameters:
key- the key.sortArgs- sort arguments.- Returns:
- List<V> array-reply list of sorted elements.
-
sort
Sort the elements in a list, set or sorted set.- Parameters:
channel- streaming channel that receives a call for every value.key- the key.sortArgs- sort arguments.- Returns:
- Long number of values.
-
sortStore
Sort the elements in a list, set or sorted set.- Parameters:
key- the key.sortArgs- sort arguments.destination- the destination key to store sort results.- Returns:
- Long number of values.
-
touch
Touch one or more keys. Touch sets the last accessed time for a key. Non-exsitent keys wont get created.- Parameters:
keys- the keys.- Returns:
- Long integer-reply the number of found keys.
-
ttl
Get the time to live for a key.- Parameters:
key- the key.- Returns:
- Long integer-reply TTL in seconds, or a negative value in order to signal an error (see the description above).
-
type
Determine the type stored at key.- Parameters:
key- the key.- Returns:
- String simple-string-reply type of
key, ornonewhenkeydoes not exist.
-
scan
KeyScanCursor<K> scan()Incrementally iterate the keys space.- Returns:
- KeyScanCursor<K> scan cursor.
-
scan
Incrementally iterate the keys space. UseKeyScanArgsto specifySCAN-specific arguments.- Parameters:
scanArgs- scan arguments.- Returns:
- KeyScanCursor<K> scan cursor.
- See Also:
KeyScanArgs
-
scan
Incrementally iterate the keys space. UseKeyScanArgsto specifySCAN-specific arguments.- Parameters:
scanCursor- cursor to resume from a previous scan, must not benull.scanArgs- scan arguments.- Returns:
- KeyScanCursor<K> scan cursor.
- See Also:
KeyScanArgs
-
scan
Incrementally iterate the keys space.- Parameters:
scanCursor- cursor to resume from a previous scan, must not benull.- Returns:
- KeyScanCursor<K> scan cursor.
-
scan
Incrementally iterate the keys space.- Parameters:
channel- streaming channel that receives a call for every key.- Returns:
- StreamScanCursor scan cursor.
-
scan
Incrementally iterate the keys space. UseKeyScanArgsto specifySCAN-specific arguments.- Parameters:
channel- streaming channel that receives a call for every key.scanArgs- scan arguments.- Returns:
- StreamScanCursor scan cursor.
- See Also:
KeyScanArgs
-
scan
Incrementally iterate the keys space. UseKeyScanArgsto specifySCAN-specific arguments.- Parameters:
channel- streaming channel that receives a call for every key.scanCursor- cursor to resume from a previous scan, must not benull.scanArgs- scan arguments.- Returns:
- StreamScanCursor scan cursor.
- See Also:
KeyScanArgs
-
scan
Incrementally iterate the keys space.- Parameters:
channel- streaming channel that receives a call for every key.scanCursor- cursor to resume from a previous scan, must not benull.- Returns:
- StreamScanCursor scan cursor.
-