Accept CompletableFuture subtypes for Lettuce pipelining.

We now no longer require RedisCommand but resort to CompletableFuture as the general asynchronous result type for Lettuce pipelining to allow subtypes such as PipelinedRedisFuture.

Closes: #2888
Original Pull Request: #2889
This commit is contained in:
Mark Paluch
2024-04-04 09:15:26 +02:00
committed by Christoph Strobl
parent 3d2fdf2a3c
commit d785b5f870
3 changed files with 42 additions and 13 deletions

View File

@@ -15,8 +15,7 @@
*/
package org.springframework.data.redis.connection.lettuce;
import io.lettuce.core.protocol.RedisCommand;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.function.Supplier;
@@ -34,7 +33,7 @@ import org.springframework.lang.Nullable;
* @since 2.1
*/
@SuppressWarnings("rawtypes")
class LettuceResult<T, R> extends FutureResult<RedisCommand<?, T, ?>> {
class LettuceResult<T, R> extends FutureResult<CompletableFuture<T>> {
private final boolean convertPipelineAndTxResults;
@@ -51,7 +50,7 @@ class LettuceResult<T, R> extends FutureResult<RedisCommand<?, T, ?>> {
LettuceResult(Future<T> resultHolder, Supplier<R> defaultReturnValue, boolean convertPipelineAndTxResults,
@Nullable Converter<T, R> converter) {
super((RedisCommand) resultHolder, converter, defaultReturnValue);
super((CompletableFuture<T>) resultHolder, converter, defaultReturnValue);
this.convertPipelineAndTxResults = convertPipelineAndTxResults;
}
@@ -59,7 +58,7 @@ class LettuceResult<T, R> extends FutureResult<RedisCommand<?, T, ?>> {
@Override
@SuppressWarnings("unchecked")
public T get() {
return (T) getResultHolder().getOutput().get();
return (T) getResultHolder().join();
}
@Override