Search code examples
javaredisjedisredis-cliredisson

how to get list of hashes in redis db using java?


Is there any way to achieve and implemen this using java program.

Currently I am referring Redis website.


Solution

  • It is not that hard if you take a good look at the Redis API in detail.

    Set<String> hashes = new HashSet<>();
    RKeys keys = redisson.getKeys();
    keys.getKeys().forEach(key -> {
        if (RType.MAP.equals(keys.getType(key))) {
            hashes.add(key);
        }
    });
    

    This is an example written using Redisson as client.