How to get all Keys from Redis using redis template

后端 未结 7 1228
误落风尘
误落风尘 2020-12-31 06:30

I have been stuck with this problem with quite some time.I want to get keys from redis using redis template. I tried this.redistemplate.keys(\"*\"); but this doesn\'t fetch

7条回答
  •  一生所求
    2020-12-31 07:06

    Solution can be like this

    String pattern = "abc"+"*";
    Set keys = jedis.keys(pattern);
    for (String key : keys) {
        jedis.keys(key);
    } 
    

    Or you can use jedis.hscan() and ScanParams instead.

提交回复
热议问题