Interface RKeys
-
- All Superinterfaces:
RKeysAsync
- All Known Implementing Classes:
RedissonKeys
public interface RKeys extends RKeysAsync
- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanclearExpire(String name)Clear an expire timeout or expire date for object.voidcopy(String name, String host, int port, int database, long timeout)Copy object from source Redis instance to destination Redis instancelongcount()Returns the number of keys in the currently-selected databaselongcountExists(String... names)Checks if provided keys existlongdelete(String... keys)Delete multiple objects by namelongdelete(RObject... objects)Delete multiple objectslongdeleteByPattern(String pattern)Delete multiple objects by a key pattern.booleanexpire(String name, long timeToLive, TimeUnit timeUnit)Set a timeout for object.booleanexpireAt(String name, long timestamp)Set an expire date for object.voidflushall()Delete all keys of all existing databasesvoidflushallParallel()Delete all keys of all existing databases in background without blocking server.voidflushdb()Delete all keys of currently selected databasevoidflushdbParallel()Delete all keys of currently selected database in background without blocking server.Iterable<String>getKeys()Get all keys using iterator.Iterable<String>getKeys(int count)Get all keys using iterator.Iterable<String>getKeysByPattern(String pattern)Get all keys by pattern using iterator.Iterable<String>getKeysByPattern(String pattern, int count)Get all keys by pattern using iterator.Stream<String>getKeysStream()Get all keys using Stream.Stream<String>getKeysStream(int count)Get all keys using Stream.Stream<String>getKeysStreamByPattern(String pattern)Get all keys by pattern using Stream.Stream<String>getKeysStreamByPattern(String pattern, int count)Get all keys by pattern using Stream.Iterable<String>getKeysWithLimit(int limit)Get keys using iterator with definedlimit.Iterable<String>getKeysWithLimit(String pattern, int limit)Get keys using iterator with definedlimit.intgetSlot(String key)Get hash slot identifier for key.RTypegetType(String key)Get Redis object type by keyvoidmigrate(String name, String host, int port, int database, long timeout)Transfer object from source Redis instance to destination Redis instancebooleanmove(String name, int database)Move object to another databaseStringrandomKey()Get random keylongremainTimeToLive(String name)Remaining time to live of Redisson object that has a timeoutvoidrename(String currentName, String newName)Rename current object key tonewNamebooleanrenamenx(String oldName, String newName)Rename object witholdNametonewNameonly if new key is not existsvoidswapdb(int db1, int db2)Swap two databases.longtouch(String... names)Update the last access time of an object.longunlink(String... keys)Delete multiple objects by name.-
Methods inherited from interface org.redisson.api.RKeysAsync
clearExpireAsync, copyAsync, countAsync, countExistsAsync, deleteAsync, deleteAsync, deleteByPatternAsync, expireAsync, expireAtAsync, flushallAsync, flushallParallelAsync, flushdbAsync, flushdbParallelAsync, getSlotAsync, getTypeAsync, migrateAsync, moveAsync, randomKeyAsync, remainTimeToLiveAsync, renameAsync, renamenxAsync, swapdbAsync, touchAsync, unlinkAsync
-
-
-
-
Method Detail
-
getKeysWithLimit
Iterable<String> getKeysWithLimit(int limit)
Get keys using iterator with definedlimit. Keys are traversed with SCAN operation.- Parameters:
limit- - limit of keys amount- Returns:
- Iterable object
-
getKeysWithLimit
Iterable<String> getKeysWithLimit(String pattern, int limit)
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
- Parameters:
limit- - limit of keys amountpattern- - match pattern- Returns:
- Iterable object
-
move
boolean move(String name, int database)
Move object to another database- Parameters:
name- of objectdatabase- - Redis database number- Returns:
trueif key was moved elsefalse
-
migrate
void migrate(String name, String host, int port, int database, long timeout)
Transfer object from source Redis instance to destination Redis instance- 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
-
copy
void copy(String name, String host, int port, int database, long timeout)
Copy object from source Redis instance to destination Redis instance- 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
-
expire
boolean expire(String name, long timeToLive, TimeUnit timeUnit)
Set a timeout for object. After the timeout has expired, the key will automatically be deleted.- Parameters:
name- of objecttimeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
expireAt
boolean expireAt(String name, long timestamp)
Set an expire date for object. When expire date comes the key will automatically be deleted.- Parameters:
name- of objecttimestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
clearExpire
boolean clearExpire(String name)
Clear an expire timeout or expire date for object.- Parameters:
name- of object- Returns:
trueif timeout was removedfalseif object does not exist or does not have an associated timeout
-
renamenx
boolean renamenx(String oldName, String newName)
Rename object witholdNametonewNameonly if new key is not exists- Parameters:
oldName- - old name of objectnewName- - new name of object- Returns:
trueif object has been renamed successfully andfalseotherwise
-
rename
void rename(String currentName, String newName)
Rename current object key tonewName- Parameters:
currentName- - current name of objectnewName- - new name of object
-
remainTimeToLive
long remainTimeToLive(String name)
Remaining time to live of Redisson object that has a timeout- 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.
-
touch
long touch(String... names)
Update the last access time of an object.- Parameters:
names- of keys- Returns:
- count of objects were touched
-
countExists
long countExists(String... names)
Checks if provided keys exist- Parameters:
names- of keys- Returns:
- amount of existing keys
-
getType
RType getType(String key)
Get Redis object type by key- Parameters:
key- - name of key- Returns:
- type of key
-
getSlot
int getSlot(String key)
Get hash slot identifier for key. Available for cluster nodes only- Parameters:
key- - name of key- Returns:
- slot number
-
getKeysByPattern
Iterable<String> getKeysByPattern(String pattern)
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
- Parameters:
pattern- - match pattern- Returns:
- Iterable object
-
getKeysByPattern
Iterable<String> getKeysByPattern(String pattern, int count)
Get all keys by pattern using iterator. Keys traversed with SCAN operation. Each SCAN operation loads up tocountkeys 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
- Parameters:
pattern- - match patterncount- - keys loaded per request to Redis- Returns:
- Iterable object
-
getKeys
Iterable<String> getKeys()
Get all keys using iterator. Keys traversing with SCAN operation. Each SCAN operation loads up to10keys per request.- Returns:
- Iterable object
-
getKeys
Iterable<String> getKeys(int count)
Get all keys using iterator. Keys traversing with SCAN operation. Each SCAN operation loads up tocountkeys per request.- Parameters:
count- - keys loaded per request to Redis- Returns:
- Iterable object
-
getKeysStreamByPattern
Stream<String> getKeysStreamByPattern(String pattern)
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
- Parameters:
pattern- - match pattern- Returns:
- Iterable object
-
getKeysStreamByPattern
Stream<String> getKeysStreamByPattern(String pattern, int count)
Get all keys by pattern using Stream. Keys traversed with SCAN operation. Each SCAN operation loads up tocountkeys 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
- Parameters:
pattern- - match patterncount- - keys loaded per request to Redis- Returns:
- Iterable object
-
getKeysStream
Stream<String> getKeysStream()
Get all keys using Stream. Keys traversing with SCAN operation. Each SCAN operation loads up to10keys per request.- Returns:
- Iterable object
-
getKeysStream
Stream<String> getKeysStream(int count)
Get all keys using Stream. Keys traversing with SCAN operation. Each SCAN operation loads up tocountkeys per request.- Parameters:
count- - keys loaded per request to Redis- Returns:
- Iterable object
-
randomKey
String randomKey()
Get random key- Returns:
- random key
-
deleteByPattern
long deleteByPattern(String pattern)
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
- Parameters:
pattern- - match pattern- Returns:
- number of removed keys
-
delete
long delete(RObject... objects)
Delete multiple objects- Parameters:
objects- of Redisson- Returns:
- number of removed keys
-
delete
long delete(String... keys)
Delete multiple objects by name- Parameters:
keys- - object names- Returns:
- number of removed keys
-
unlink
long unlink(String... keys)
Delete multiple objects by name. Actual removal will happen later asynchronously.Requires Redis 4.0+
- Parameters:
keys- of objects- Returns:
- number of removed keys
-
count
long count()
Returns the number of keys in the currently-selected database- Returns:
- count of keys
-
swapdb
void swapdb(int db1, int db2)Swap two databases.
-
flushdb
void flushdb()
Delete all keys of currently selected database
-
flushdbParallel
void flushdbParallel()
Delete all keys of currently selected database in background without blocking server.Requires Redis 4.0+
-
flushall
void flushall()
Delete all keys of all existing databases
-
flushallParallel
void flushallParallel()
Delete all keys of all existing databases in background without blocking server.Requires Redis 4.0+
-
-