public static Set<String> getAllKey(String match,int count){
//返回集
Set<String> binKeys=new HashSet<>();
//封装scan查询参数
ScanParams param=new ScanParams().match(match).count(count);
//获取查询对象
RedisCacheServiceImpl redisCacheSer=(RedisCacheServiceImpl)RedisCacheService;
JedisCluster jedisClu=redisCacheSer.getJedisCluster();
//getClueterNodes获取集群节点,从各个集群中获取值进行遍历
jedisClu.getClusterNodes().values().stream().forEach(pool->{
boolean done=false;//
String cur=”0″;//游标,以0开始,返回0代表一次结束
try(Jedis jedisNode=pool.getResource()){
while(!done){
ScanResult<String> scanResult=jedisNode.scan(cur,param);
cur=scanResult.getStringCursor();
if(“0”.equals(cur){done=true};
List<String> result=scanResult.getResult();
result.foreach(data->{binKeys.add(data)});
}
}
});
return binKeys;
}
//返回集
Set<String> binKeys=new HashSet<>();
//封装scan查询参数
ScanParams param=new ScanParams().match(match).count(count);
//获取查询对象
RedisCacheServiceImpl redisCacheSer=(RedisCacheServiceImpl)RedisCacheService;
JedisCluster jedisClu=redisCacheSer.getJedisCluster();
//getClueterNodes获取集群节点,从各个集群中获取值进行遍历
jedisClu.getClusterNodes().values().stream().forEach(pool->{
boolean done=false;//
String cur=”0″;//游标,以0开始,返回0代表一次结束
try(Jedis jedisNode=pool.getResource()){
while(!done){
ScanResult<String> scanResult=jedisNode.scan(cur,param);
cur=scanResult.getStringCursor();
if(“0”.equals(cur){done=true};
List<String> result=scanResult.getResult();
result.foreach(data->{binKeys.add(data)});
}
}
});
return binKeys;
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。