Class RedissonKeys
- All Implemented Interfaces:
RKeys
,RKeysAsync
- Author:
- Nikita Koksharov
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
clearExpire
(String name) Clear an expire timeout or expire date for object.clearExpireAsync
(String name) Clear an expire timeout or expire date for object.void
Copy object from source Redis instance to destination Redis instanceCopy object from source Redis instance to destination Redis instance in async modelong
count()
Returns the number of keys in the currently-selected databaseReturns the number of keys in the currently-selected database in async modelong
countExists
(String... names) Checks if provided keys existcountExistsAsync
(String... names) Checks if provided keys existlong
Delete multiple objects by namelong
Delete multiple objectsdeleteAsync
(String... keys) Delete multiple objects by namedeleteAsync
(RObject... objects) Delete multiple objectslong
deleteByPattern
(String pattern) Delete multiple objects by a key pattern.deleteByPatternAsync
(String pattern) Delete multiple objects by a key pattern.boolean
Set a timeout for object.expireAsync
(String name, long timeToLive, TimeUnit timeUnit) Set a timeout for object.boolean
Set an expire date for object.expireAtAsync
(String name, long timestamp) Set an expire date for object.void
flushall()
Delete all keys of all existing databasesDelete all keys of all existing databasesvoid
Delete all keys of all existing databases in background without blocking server.Delete all keys of all existing databases in background without blocking server.void
flushdb()
Delete all keys of currently selected databaseDelete all keys of currently selected databasevoid
Delete all keys of currently selected database in background without blocking server.Delete all keys of currently selected database in background without blocking server.getKeys()
Get all keys using iterator.getKeys
(int count) Get all keys using iterator.getKeysByPattern
(String pattern) Get all keys by pattern using iterator.getKeysByPattern
(String pattern, int count) Get all keys by pattern using iterator.<T> Iterable<T>
getKeysByPattern
(RedisCommand<?> command, String pattern, int limit, int count) Get all keys using Stream.getKeysStream
(int count) Get all keys using Stream.getKeysStreamByPattern
(String pattern) Get all keys by pattern using Stream.getKeysStreamByPattern
(String pattern, int count) Get all keys by pattern using Stream.getKeysWithLimit
(int limit) Get keys using iterator with definedlimit
.getKeysWithLimit
(String pattern, int limit) Get keys using iterator with definedlimit
.int
Get hash slot identifier for key.getSlotAsync
(String key) Get hash slot identifier for key in async mode.Get Redis object type by keygetTypeAsync
(String key) Get Redis object type by keyvoid
Transfer object from source Redis instance to destination Redis instancemigrateAsync
(String name, String host, int port, int database, long timeout) Transfer object from source Redis instance to destination Redis instanceboolean
Move object to another databaseMove object to another databaseGet random keyGet random key in async modelong
remainTimeToLive
(String name) Remaining time to live of Redisson object that has a timeoutremainTimeToLiveAsync
(String name) Remaining time to live of Redisson object that has a timeoutvoid
Rename current object key tonewName
renameAsync
(String currentName, String newName) Rename current object key tonewName
boolean
Rename object witholdName
tonewName
only if new key is not existsrenamenxAsync
(String oldName, String newName) Rename object witholdName
tonewName
only if new key is not existsscanIteratorAsync
(RedisClient client, MasterSlaveEntry entry, long startPos, String pattern, int count) void
swapdb
(int db1, int db2) Swap two databases.swapdbAsync
(int db1, int db2) Swap two databases.protected <T> Stream<T>
long
Update the last access time of an object.touchAsync
(String... names) Update the last access time of an object.long
Delete multiple objects by name.unlinkAsync
(String... keys) Delete multiple objects by name.
-
Constructor Details
-
RedissonKeys
-
-
Method Details
-
getCommandExecutor
-
getConnectionManager
-
getType
Description copied from interface:RKeys
Get Redis object type by key -
getTypeAsync
Description copied from interface:RKeysAsync
Get Redis object type by key- Specified by:
getTypeAsync
in interfaceRKeysAsync
- Parameters:
key
- - name of key- Returns:
- type of key
-
getSlot
Description copied from interface:RKeys
Get hash slot identifier for key. Available for cluster nodes only -
getSlotAsync
Description copied from interface:RKeysAsync
Get hash slot identifier for key in async mode. Available for cluster nodes only- Specified by:
getSlotAsync
in interfaceRKeysAsync
- Parameters:
key
- - name of key- Returns:
- slot
-
getKeysByPattern
Description copied from interface:RKeys
Get all keys by pattern using iterator. Keys traversed with SCAN operation. Each SCAN operation loads up to 10 keys per request.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
getKeysByPattern
in interfaceRKeys
- Parameters:
pattern
- - match pattern- Returns:
- Iterable object
-
getKeysByPattern
Description copied from interface:RKeys
Get all keys by pattern using iterator. Keys traversed with SCAN operation. Each SCAN operation loads up tocount
keys per request.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
getKeysByPattern
in interfaceRKeys
- Parameters:
pattern
- - match patterncount
- - keys loaded per request to Redis- Returns:
- Iterable object
-
getKeysByPattern
public <T> Iterable<T> getKeysByPattern(RedisCommand<?> command, String pattern, int limit, int count) -
getKeysWithLimit
Description copied from interface:RKeys
Get keys using iterator with definedlimit
. Keys are traversed with SCAN operation.- Specified by:
getKeysWithLimit
in interfaceRKeys
- Parameters:
limit
- - limit of keys amount- Returns:
- Iterable object
-
getKeysWithLimit
Description copied from interface:RKeys
Get keys using iterator with definedlimit
. Keys are traversed with SCAN operation.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
getKeysWithLimit
in interfaceRKeys
- Parameters:
pattern
- - match patternlimit
- - limit of keys amount- Returns:
- Iterable object
-
getKeys
Description copied from interface:RKeys
Get all keys using iterator. Keys traversing with SCAN operation. Each SCAN operation loads up to10
keys per request. -
getKeys
Description copied from interface:RKeys
Get all keys using iterator. Keys traversing with SCAN operation. Each SCAN operation loads up tocount
keys per request. -
scanIteratorAsync
public RFuture<ScanResult<Object>> scanIteratorAsync(RedisClient client, MasterSlaveEntry entry, long startPos, String pattern, int count) -
touch
Description copied from interface:RKeys
Update the last access time of an object. -
touchAsync
Description copied from interface:RKeysAsync
Update the last access time of an object.- Specified by:
touchAsync
in interfaceRKeysAsync
- Parameters:
names
- of keys- Returns:
- count of objects were touched
-
countExists
Description copied from interface:RKeys
Checks if provided keys exist- Specified by:
countExists
in interfaceRKeys
- Parameters:
names
- of keys- Returns:
- amount of existing keys
-
countExistsAsync
Description copied from interface:RKeysAsync
Checks if provided keys exist- Specified by:
countExistsAsync
in interfaceRKeysAsync
- Parameters:
names
- of keys- Returns:
- amount of existing keys
-
randomKey
Description copied from interface:RKeys
Get random key -
randomKeyAsync
Description copied from interface:RKeysAsync
Get random key in async mode- Specified by:
randomKeyAsync
in interfaceRKeysAsync
- Returns:
- random key
-
deleteByPattern
Description copied from interface:RKeys
Delete multiple objects by a key pattern.Method executes in NON atomic way in cluster mode due to lua script limitations.
Supported glob-style patterns: h?llo subscribes to hello, hallo and hxllo h*llo subscribes to hllo and heeeello h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
deleteByPattern
in interfaceRKeys
- Parameters:
pattern
- - match pattern- Returns:
- number of removed keys
-
deleteByPatternAsync
Description copied from interface:RKeysAsync
Delete multiple objects by a key pattern.Method executes in NON atomic way in cluster mode due to lua script limitations.
Supported glob-style patterns: h?llo subscribes to hello, hallo and hxllo h*llo subscribes to hllo and heeeello h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
deleteByPatternAsync
in interfaceRKeysAsync
- Parameters:
pattern
- - match pattern- Returns:
- number of removed keys
-
delete
Description copied from interface:RKeys
Delete multiple objects by name -
delete
Description copied from interface:RKeys
Delete multiple objects -
deleteAsync
Description copied from interface:RKeysAsync
Delete multiple objects- Specified by:
deleteAsync
in interfaceRKeysAsync
- Parameters:
objects
- of Redisson- Returns:
- number of removed keys
-
unlink
Description copied from interface:RKeys
Delete multiple objects by name. Actual removal will happen later asynchronously.Requires Redis 4.0+
-
unlinkAsync
Description copied from interface:RKeysAsync
Delete multiple objects by name. Actual removal will happen later asynchronously.Requires Redis 4.0+
- Specified by:
unlinkAsync
in interfaceRKeysAsync
- Parameters:
keys
- - object names- Returns:
- number of removed keys
-
deleteAsync
Description copied from interface:RKeysAsync
Delete multiple objects by name- Specified by:
deleteAsync
in interfaceRKeysAsync
- Parameters:
keys
- - object names- Returns:
- number of removed keys
-
count
public long count()Description copied from interface:RKeys
Returns the number of keys in the currently-selected database -
countAsync
Description copied from interface:RKeysAsync
Returns the number of keys in the currently-selected database in async mode- Specified by:
countAsync
in interfaceRKeysAsync
- Returns:
- number of keys
-
flushdbParallel
public void flushdbParallel()Description copied from interface:RKeys
Delete all keys of currently selected database in background without blocking server.Requires Redis 4.0+
- Specified by:
flushdbParallel
in interfaceRKeys
-
flushdbParallelAsync
Description copied from interface:RKeysAsync
Delete all keys of currently selected database in background without blocking server.Requires Redis 4.0+
- Specified by:
flushdbParallelAsync
in interfaceRKeysAsync
- Returns:
- void
-
flushallParallel
public void flushallParallel()Description copied from interface:RKeys
Delete all keys of all existing databases in background without blocking server.Requires Redis 4.0+
- Specified by:
flushallParallel
in interfaceRKeys
-
flushallParallelAsync
Description copied from interface:RKeysAsync
Delete all keys of all existing databases in background without blocking server.Requires Redis 4.0+
- Specified by:
flushallParallelAsync
in interfaceRKeysAsync
- Returns:
- void
-
flushdb
public void flushdb()Description copied from interface:RKeys
Delete all keys of currently selected database -
flushdbAsync
Description copied from interface:RKeysAsync
Delete all keys of currently selected database- Specified by:
flushdbAsync
in interfaceRKeysAsync
- Returns:
- void
-
flushall
public void flushall()Description copied from interface:RKeys
Delete all keys of all existing databases -
flushallAsync
Description copied from interface:RKeysAsync
Delete all keys of all existing databases- Specified by:
flushallAsync
in interfaceRKeysAsync
- Returns:
- void
-
remainTimeToLive
Description copied from interface:RKeys
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLive
in interfaceRKeys
- Parameters:
name
- of key- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
remainTimeToLiveAsync
Description copied from interface:RKeysAsync
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsync
in interfaceRKeysAsync
- Parameters:
name
- of key- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
rename
Description copied from interface:RKeys
Rename current object key tonewName
-
renameAsync
Description copied from interface:RKeysAsync
Rename current object key tonewName
- Specified by:
renameAsync
in interfaceRKeysAsync
- Parameters:
currentName
- - current name of objectnewName
- - new name of object- Returns:
- void
-
renamenx
Description copied from interface:RKeys
Rename object witholdName
tonewName
only if new key is not exists -
renamenxAsync
Description copied from interface:RKeysAsync
Rename object witholdName
tonewName
only if new key is not exists- Specified by:
renamenxAsync
in interfaceRKeysAsync
- Parameters:
oldName
- - old name of objectnewName
- - new name of object- Returns:
true
if object has been renamed successfully andfalse
otherwise
-
clearExpire
Description copied from interface:RKeys
Clear an expire timeout or expire date for object.- Specified by:
clearExpire
in interfaceRKeys
- Parameters:
name
- of object- Returns:
true
if timeout was removedfalse
if object does not exist or does not have an associated timeout
-
clearExpireAsync
Description copied from interface:RKeysAsync
Clear an expire timeout or expire date for object.- Specified by:
clearExpireAsync
in interfaceRKeysAsync
- Parameters:
name
- of object- Returns:
true
if timeout was removedfalse
if object does not exist or does not have an associated timeout
-
expireAt
Description copied from interface:RKeys
Set an expire date for object. When expire date comes the key will automatically be deleted. -
expireAtAsync
Description copied from interface:RKeysAsync
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAtAsync
in interfaceRKeysAsync
- Parameters:
name
- of objecttimestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expire
Description copied from interface:RKeys
Set a timeout for object. After the timeout has expired, the key will automatically be deleted. -
expireAsync
Description copied from interface:RKeysAsync
Set a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRKeysAsync
- Parameters:
name
- of objecttimeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
migrate
Description copied from interface:RKeys
Transfer object from source Redis instance to destination Redis instance -
migrateAsync
Description copied from interface:RKeysAsync
Transfer object from source Redis instance to destination Redis instance- Specified by:
migrateAsync
in interfaceRKeysAsync
- Parameters:
name
- of objecthost
- - destination hostport
- - destination portdatabase
- - destination databasetimeout
- - maximum idle time in any moment of the communication with the destination instance in milliseconds- Returns:
- void
-
copy
Description copied from interface:RKeys
Copy object from source Redis instance to destination Redis instance -
copyAsync
Description copied from interface:RKeysAsync
Copy object from source Redis instance to destination Redis instance in async mode- Specified by:
copyAsync
in interfaceRKeysAsync
- Parameters:
name
- of objecthost
- - destination hostport
- - destination portdatabase
- - destination databasetimeout
- - maximum idle time in any moment of the communication with the destination instance in milliseconds- Returns:
- void
-
move
Description copied from interface:RKeys
Move object to another database -
moveAsync
Description copied from interface:RKeysAsync
Move object to another database- Specified by:
moveAsync
in interfaceRKeysAsync
- Parameters:
name
- of objectdatabase
- - Redis database number- Returns:
true
if key was moved elsefalse
-
getKeysStreamByPattern
Description copied from interface:RKeys
Get all keys by pattern using Stream. Keys traversed with SCAN operation. Each SCAN operation loads up to 10 keys per request.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
getKeysStreamByPattern
in interfaceRKeys
- Parameters:
pattern
- - match pattern- Returns:
- Iterable object
-
toStream
-
getKeysStreamByPattern
Description copied from interface:RKeys
Get all keys by pattern using Stream. Keys traversed with SCAN operation. Each SCAN operation loads up tocount
keys per request.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
getKeysStreamByPattern
in interfaceRKeys
- Parameters:
pattern
- - match patterncount
- - keys loaded per request to Redis- Returns:
- Iterable object
-
getKeysStream
Description copied from interface:RKeys
Get all keys using Stream. Keys traversing with SCAN operation. Each SCAN operation loads up to10
keys per request.- Specified by:
getKeysStream
in interfaceRKeys
- Returns:
- Iterable object
-
getKeysStream
Description copied from interface:RKeys
Get all keys using Stream. Keys traversing with SCAN operation. Each SCAN operation loads up tocount
keys per request.- Specified by:
getKeysStream
in interfaceRKeys
- Parameters:
count
- - keys loaded per request to Redis- Returns:
- Iterable object
-
swapdb
public void swapdb(int db1, int db2) Description copied from interface:RKeys
Swap two databases. -
swapdbAsync
Description copied from interface:RKeysAsync
Swap two databases.Requires Redis 4.0+
- Specified by:
swapdbAsync
in interfaceRKeysAsync
- Returns:
- void
-