每个Redisson对象实例都会有一个与之对应的Redis数据实例,可以通过调用getName
方法来取得Redis数据实例的名称(key)。
RMap map = redisson.getMap("mymap");
map.getName(); // = mymap
所有与Redis key相关的操作都归纳在RKeys
这个接口里:
RKeys keys = redisson.getKeys();
Iterable<String> allKeys = keys.getKeys();
Iterable<String> foundedKeys = keys.getKeysByPattern('key*');
long numOfDeletedKeys = keys.delete("obj1", "obj2", "obj3");
long deletedKeysAmount = keys.deleteByPattern("test?");
String randomKey = keys.randomKey();
long keysAmount = keys.count();