Hi team,
I am running a code snippet
ScanArgs scanArgs = new ScanArgs().match("myKey:*").limit(1000);
KeyScanCursor<byte[]> keyScanCursor = RedisLettuceExecutor.executeRedis(redisDataSource,
redisAdvancedClusterCommands -> redisAdvancedClusterCommands.scan(scanArgs));
resultKeys.addAll(keyScanCursor.getKeys());
log.info("[lettuce] current cursor: {}", keyScanCursor.getCursor());
log.info("[lettuce] current cursor key size: {}", keyScanCursor.getKeys().size());
Thread.sleep(sleep);
while (!keyScanCursor.getCursor().equalsIgnoreCase("0")){
Thread.sleep(waitingTime);
numTimeFallAsSleep++;
keyScanCursor = scan(ScanCursor.of(keyScanCursor.getCursor()), scanArgs);
resultKeys.addAll(keyScanCursor.getKeys());
}
private KeyScanCursor<byte[]> scan(ScanCursor scanCursor, ScanArgs scanArgs) {
log.info("[Lettuce Tee4j] previous cursor: {}", scanCursor.getCursor());
KeyScanCursor<byte[]> keyScanCursor = RedisLettuceExecutor.executeRedis(redisDataSource, redisAdvancedClusterCommands -> redisAdvancedClusterCommands.scan(scanCursor, scanArgs));
log.info("[Lettuce] current cursor: {}", keyScanCursor.getCursor());
log.info("[Lettuce] current cursor keys size: {}", keyScanCursor.getKeys().size());
return keyScanCursor;
}
But the code runs only once, The Previous and current cursor value is same but i keep getting Exception "java.lang.IllegalArgumentException: A scan in Redis Cluster mode requires to reuse the resulting cursor from the previous scan invocation"