How to get all Keys from Redis using redis template

后端 未结 7 1166
误落风尘
误落风尘 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:15

    try:

    Set keys = RedisTemplate.getConnectionFactory().getConnection().keys("*".getBytes());
    
    Iterator it = keys.iterator();
    
    while(it.hasNext()){
    
        byte[] data = (byte[])it.next();
    
        System.out.println(new String(data, 0, data.length));
    }
    

提交回复
热议问题