Redisson provides asynchronous pipeline in more convenient way. Here is code example:
RBatch batch = redisson.createBatch();
RFuture<String> mapFuture = batch.getMap("test").putAsync("2", "5");
RFuture<Long> longFuture = batch.getAtomicLongAsync("counter").incrementAndGetAsync();
List<?> res = batch.execute();
// or
RFuture<List<?>> asyncRes = batch.executeAsync();
Asynchronous methods returns RFuture
object which implements both CompletionStage and Future interfaces.
Further, you can get result
mapFuture.get()
result or asyncRes.get()[0]
Binding listeners:
future.whenComplete((res, exception) -> {
// handle both result and exception
});
// or
future.thenAccept(res -> {
// handle result
}).exceptionally(exception -> {
// handle exception
});