How to get all Keys from Redis using redis template

后端 未结 7 1168
误落风尘
误落风尘 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<byte[]> keys = RedisTemplate.getConnectionFactory().getConnection().keys("*".getBytes());
    
    Iterator<byte[]> it = keys.iterator();
    
    while(it.hasNext()){
    
        byte[] data = (byte[])it.next();
    
        System.out.println(new String(data, 0, data.length));
    }
    
    0 讨论(0)
提交回复
热议问题