public interface RedisKeyCommands
Modifier and Type | Method and Description |
---|---|
Boolean |
copy(byte[] sourceKey,
byte[] targetKey,
boolean replace)
Copy given
sourceKey to targetKey . |
Long |
del(byte[]... keys)
Delete given
keys . |
byte[] |
dump(byte[] key)
Retrieve serialized version of the value stored at
key . |
ValueEncoding |
encodingOf(byte[] key)
Get the type of internal representation used for storing the value at the given
key . |
Long |
exists(byte[]... keys)
Count how many of the given
keys exist. |
default Boolean |
exists(byte[] key)
Determine if given
key exists. |
Boolean |
expire(byte[] key,
long seconds)
Set time to live for given
key in seconds. |
Boolean |
expireAt(byte[] key,
long unixTime)
Set the expiration for given
key as a UNIX timestamp. |
Duration |
idletime(byte[] key)
Get the
Duration since the object stored at the given key is idle. |
Set<byte[]> |
keys(byte[] pattern)
Find all keys matching the given
pattern . |
Boolean |
move(byte[] key,
int dbIndex)
Move given
key to database with index . |
Boolean |
persist(byte[] key)
Remove the expiration from given
key . |
Boolean |
pExpire(byte[] key,
long millis)
Set time to live for given
key in milliseconds. |
Boolean |
pExpireAt(byte[] key,
long unixTimeInMillis)
Set the expiration for given
key as a UNIX timestamp in milliseconds. |
Long |
pTtl(byte[] key)
Get the precise time to live for
key in milliseconds. |
Long |
pTtl(byte[] key,
TimeUnit timeUnit)
Get the precise time to live for
key in and convert it to the given TimeUnit . |
byte[] |
randomKey()
Return a random key from the keyspace.
|
Long |
refcount(byte[] key)
Get the number of references of the value associated with the specified
key . |
void |
rename(byte[] oldKey,
byte[] newKey)
Rename key
oldKey to newKey . |
Boolean |
renameNX(byte[] oldKey,
byte[] newKey)
Rename key
oldKey to newKey only if newKey does not exist. |
default void |
restore(byte[] key,
long ttlInMillis,
byte[] serializedValue)
|
void |
restore(byte[] key,
long ttlInMillis,
byte[] serializedValue,
boolean replace)
|
default Cursor<byte[]> |
scan(KeyScanOptions options)
Use a
Cursor to iterate over keys. |
Cursor<byte[]> |
scan(ScanOptions options)
Use a
Cursor to iterate over keys. |
List<byte[]> |
sort(byte[] key,
SortParameters params)
Sort the elements for
key . |
Long |
sort(byte[] key,
SortParameters params,
byte[] storeKey)
Sort the elements for
key and store result in storeKey . |
Long |
touch(byte[]... keys)
Alter the last access time of given
key(s) . |
Long |
ttl(byte[] key)
Get the time to live for
key in seconds. |
Long |
ttl(byte[] key,
TimeUnit timeUnit)
Get the time to live for
key in and convert it to the given TimeUnit . |
DataType |
type(byte[] key)
Determine the type stored at
key . |
Long |
unlink(byte[]... keys)
Unlink the
keys from the keyspace. |
@Nullable Boolean copy(byte[] sourceKey, byte[] targetKey, boolean replace)
sourceKey
to targetKey
.sourceKey
- must not be null.targetKey
- must not be null.replace
- whether to replace existing keys.@Nullable default Boolean exists(byte[] key)
key
exists.key
- must not be null.@Nullable Long exists(byte[]... keys)
keys
exist. Providing the very same key
more than once also counts
multiple times.keys
- must not be null.@Nullable Long del(byte[]... keys)
keys
.keys
- must not be null.@Nullable Long unlink(byte[]... keys)
keys
from the keyspace. Unlike with #del(byte[]...)
the actual memory reclaiming here
happens asynchronously.keys
- must not be null.@Nullable DataType type(byte[] key)
key
.key
- must not be null.@Nullable Long touch(byte[]... keys)
key(s)
.keys
- must not be null.@Nullable Set<byte[]> keys(byte[] pattern)
pattern
.pattern
- must not be null.Set
if no match found. null when used in pipeline / transaction.default Cursor<byte[]> scan(KeyScanOptions options)
Cursor
to iterate over keys.options
- must not be null.Cursor<byte[]> scan(ScanOptions options)
Cursor
to iterate over keys.options
- must not be null.@Nullable byte[] randomKey()
void rename(byte[] oldKey, byte[] newKey)
oldKey
to newKey
.oldKey
- must not be null.newKey
- must not be null.@Nullable Boolean renameNX(byte[] oldKey, byte[] newKey)
oldKey
to newKey
only if newKey
does not exist.oldKey
- must not be null.newKey
- must not be null.@Nullable Boolean expire(byte[] key, long seconds)
key
in seconds.key
- must not be null.seconds
- @Nullable Boolean pExpire(byte[] key, long millis)
key
in milliseconds.key
- must not be null.millis
- @Nullable Boolean expireAt(byte[] key, long unixTime)
key
as a UNIX timestamp.key
- must not be null.unixTime
- @Nullable Boolean pExpireAt(byte[] key, long unixTimeInMillis)
key
as a UNIX timestamp in milliseconds.key
- must not be null.unixTimeInMillis
- @Nullable Boolean persist(byte[] key)
key
.key
- must not be null.@Nullable Boolean move(byte[] key, int dbIndex)
key
to database with index
.key
- must not be null.dbIndex
- @Nullable Long ttl(byte[] key)
key
in seconds.key
- must not be null.@Nullable Long ttl(byte[] key, TimeUnit timeUnit)
key
in and convert it to the given TimeUnit
.key
- must not be null.timeUnit
- must not be null.@Nullable Long pTtl(byte[] key)
key
in milliseconds.key
- must not be null.@Nullable Long pTtl(byte[] key, TimeUnit timeUnit)
key
in and convert it to the given TimeUnit
.key
- must not be null.timeUnit
- must not be null.@Nullable List<byte[]> sort(byte[] key, SortParameters params)
key
.key
- must not be null.params
- must not be null.@Nullable Long sort(byte[] key, SortParameters params, byte[] storeKey)
key
and store result in storeKey
.key
- must not be null.params
- must not be null.storeKey
- must not be null.@Nullable byte[] dump(byte[] key)
key
.key
- must not be null.default void restore(byte[] key, long ttlInMillis, byte[] serializedValue)
key
- must not be null.ttlInMillis
- serializedValue
- must not be null.void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolean replace)
key
- must not be null.ttlInMillis
- serializedValue
- must not be null.replace
- use true to replace a potentially existing value instead of erroring.@Nullable ValueEncoding encodingOf(byte[] key)
key
.key
- must not be null.ValueEncoding.RedisValueEncoding.VACANT
if key does not
exist or null when used in pipeline / transaction.IllegalArgumentException
- if key
is null.@Nullable Duration idletime(byte[] key)
Duration
since the object stored at the given key
is idle.key
- must not be null.IllegalArgumentException
- if key
is null.@Nullable Long refcount(byte[] key)
key
.key
- must not be null.IllegalArgumentException
- if key
is null.Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.