public class RedisCallback<KEY,REQUEST,RESPONSE> extends java.lang.Object implements RedisMessageListener
限定符和类型 | 类和说明 |
---|---|
static class |
RedisCallback.Builder<KEY,REQUEST,RESPONSE> |
限定符和类型 | 字段和说明 |
---|---|
protected @NotNull java.util.Map<KEY,java.util.concurrent.CompletableFuture<RESPONSE>> |
pendingRequests |
protected @NotNull java.lang.String |
requestChannel |
protected @NotNull java.util.function.Function<REQUEST,KEY> |
requestKey |
protected @NotNull java.util.function.BiConsumer<com.google.common.io.ByteArrayDataOutput,REQUEST> |
requestSerializer |
protected @NotNull java.lang.String |
responseChannel |
protected @NotNull java.util.function.Function<RedisMessage,KEY> |
responseKey |
protected @NotNull java.util.function.Function<RedisMessage,RESPONSE> |
responseParser |
构造器和说明 |
---|
RedisCallback(@NotNull java.lang.String requestChannel,
@NotNull java.lang.String responseChannel,
@NotNull java.util.function.Function<REQUEST,KEY> requestKey,
@NotNull java.util.function.Function<RedisMessage,KEY> responseKey,
@NotNull java.util.function.BiConsumer<com.google.common.io.ByteArrayDataOutput,REQUEST> requestSerializer,
@NotNull java.util.function.Function<RedisMessage,RESPONSE> responseParser) |
限定符和类型 | 方法和说明 |
---|---|
java.util.concurrent.CompletableFuture<RESPONSE> |
call(REQUEST request) |
java.util.concurrent.CompletableFuture<RESPONSE> |
call(@NotNull java.util.function.Supplier<REQUEST> request) |
void |
cancel(KEY key) |
static <KEY,REQUEST,RESPONSE> |
create(@NotNull java.lang.Class<KEY> keyClass,
@NotNull java.lang.Class<REQUEST> requestClazz,
@NotNull java.lang.Class<RESPONSE> responseClazz)
创建一个新的 RedisCallback.Builder 实例,用于构建 RedisCallback。
|
@Nullable java.util.concurrent.CompletableFuture<RESPONSE> |
get(KEY key) |
void |
handle(RedisMessage message) |
KEY |
keyOf(@NotNull RedisMessage response) |
KEY |
keyOf(REQUEST request) |
@NotNull java.util.Map<KEY,java.util.concurrent.CompletableFuture<RESPONSE>> |
pendingRequests() |
@NotNull java.lang.String |
requestChannel() |
@NotNull java.lang.String |
responseChannel() |
void |
shutdown()
取消所有挂起的请求,并清理相关资源。
|
@NotNull protected final @NotNull java.lang.String requestChannel
@NotNull protected final @NotNull java.lang.String responseChannel
@NotNull protected final @NotNull java.util.function.BiConsumer<com.google.common.io.ByteArrayDataOutput,REQUEST> requestSerializer
@NotNull protected final @NotNull java.util.function.Function<RedisMessage,KEY> responseKey
@NotNull protected final @NotNull java.util.function.Function<RedisMessage,RESPONSE> responseParser
public RedisCallback(@NotNull @NotNull java.lang.String requestChannel, @NotNull @NotNull java.lang.String responseChannel, @NotNull @NotNull java.util.function.Function<REQUEST,KEY> requestKey, @NotNull @NotNull java.util.function.Function<RedisMessage,KEY> responseKey, @NotNull @NotNull java.util.function.BiConsumer<com.google.common.io.ByteArrayDataOutput,REQUEST> requestSerializer, @NotNull @NotNull java.util.function.Function<RedisMessage,RESPONSE> responseParser)
public static <KEY,REQUEST,RESPONSE> RedisCallback.Builder<KEY,REQUEST,RESPONSE> create(@NotNull @NotNull java.lang.Class<KEY> keyClass, @NotNull @NotNull java.lang.Class<REQUEST> requestClazz, @NotNull @NotNull java.lang.Class<RESPONSE> responseClazz)
KEY
- 请求和响应的键类型,用于标识请求和响应的唯一性。REQUEST
- 请求消息的类型参数,通常是一个具体的类。RESPONSE
- 响应消息的类型参数,通常是一个具体的类。requestClazz
- 请求消息的类类型,用于序列化和反序列化。responseClazz
- 响应消息的类类型,用于解析响应。@NotNull public @NotNull java.lang.String requestChannel()
@NotNull public @NotNull java.lang.String responseChannel()
@NotNull public @NotNull java.util.Map<KEY,java.util.concurrent.CompletableFuture<RESPONSE>> pendingRequests()
@Nullable public @Nullable java.util.concurrent.CompletableFuture<RESPONSE> get(@NotNull KEY key)
public void cancel(@NotNull KEY key)
public void shutdown()
public void handle(RedisMessage message)
handle
在接口中 RedisMessageListener
public java.util.concurrent.CompletableFuture<RESPONSE> call(@NotNull @NotNull java.util.function.Supplier<REQUEST> request)
@NotNull public KEY keyOf(@NotNull @NotNull RedisMessage response)
Copyright © 2025. All rights reserved.