How to get Key & Value both from RedisFuture while using RedisAsyncCommands in Lettuce.
RedisClient redisClient = RedisClient .create("redis://localhost:6379/");
StatefulRedisConnection<String, String> connection = redisClient.connect();
RedisAsyncCommands<String, String> commands = connection.async();
// disable auto-flushing
commands.setAutoFlushCommands(false);
List<RedisFuture<?>> futures = new ArrayList<>();
for (int i = 0; i < 10; i++) {
futures.add(commands.get("key-" + i));
}
commands.flushCommands();
for(RedisFuture future : futures) {
System.out.println(future.get()); //Giving only values.
}
connection.close();
So my expectation is I need the key object as well along with value from RedisFuture object. This is because in my real example, there can be a possibility that there will be no value for a specific key so i need to have information that for which keys i got the data from cache and so i can create a map out of it.
Please ignore my typos & grammar mistakes.