我正在使用Redis Lettuce动态客户端,如官方文档https://github.com/lettuce-io/lettuce-core/wiki/Redis-Command-Interfaces#command-interfaces.response-types
中所述我的命令界面看起来完全一样
public interface RedisCommands extends Commands {
@Command("GET")
Mono<String> get(String key);
Mono<Boolean> expire(String key, long seconds);
}
问题是当方法get
无法通过键找到值时,抛出了异常,而不是返回空的Mono。
java.lang.IllegalArgumentException: Data must not be null
at io.lettuce.core.internal.LettuceAssert.notNull(LettuceAssert.java:58)
at io.lettuce.core.RedisPublisher$RedisSubscription.onNext(RedisPublisher.java:251)
at io.lettuce.core.output.StreamingOutput$Subscriber.onNext(StreamingOutput.java:64)
at io.lettuce.core.output.KeyListOutput.set(KeyListOutput.java:45)
at io.lettuce.core.protocol.RedisStateMachine.safeSet(RedisStateMachine.java:373)
at io.lettuce.core.protocol.RedisStateMachine.decode(RedisStateMachine.java:146)
at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:624)
使用预定义的RedisReactiveCommands get可以正常工作时,它返回空的Mono。所以对我来说,这似乎是个错误。
正在使用的Redis生菜版本是
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>