I would like to get all the keys from Redis cluster using Jedis with the following code snippet:
public void testRedis() {
String key = "*";
ScanParams scanParams = new ScanParams().count(1000).match("{*}");
String cur = SCAN_POINTER_START;
do {
ScanResult<String> scanResult = getRedisCluster().scan(cur, scanParams);
scanResult.getResult().stream().forEach(System.out::println);
cur = scanResult.getStringCursor();
} while (!cur.equals(SCAN_POINTER_START));
}
My problem is that it doesn't return any result with this solution. Even if I specify the matching pattern for an existing key it's still not working. I tried to get specific keys with get command it returns value without any error, so the connection seems good.
Any suggestion? (One of my clue is that match parameter waiting for "curly-brackets" so I had to add there, but I haven't seen using this like that on internet anywhere.)