Linux 拨号vps windows公众号手机端

redis如何循环遍历key

lewis 7年前 (2018-11-29) 阅读数 9 #VPS/云服务器
文章标签 keyredis

redis循环遍历key的示例:

@Test

public void test12(){

Jedis jedis = new Jedis("x.x.x.x", 6379);

jedis.auth("xxx");

long start = System.currentTimeMillis();

String cursor = "0";

do {

ScanParams scanParams = new ScanParams();

scanParams.match("hello*");

ScanResult scan = jedis.scan(cursor, scanParams);

List result = scan.getResult();

result.forEach(x->{

System.out.println(x);

});

cursor = scan.getStringCursor();

}while (!StringUtils.equals("0",cursor));

long end = System.currentTimeMillis();

System.out.println(new Double(end-start)/1000d);

}

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门