我用LettuceConnectionFactory定义了RedisTemplate,但是我不知道如何在https://github.com/lettuce-io/lettuce-core/wiki/Connection-Events中创建连接事件。
如何使用RedisTemplate获取RedisClient实例?
答案 0 :(得分:0)
为此,我重写了LettuceConnectionFactory,并放置了ClientResources:
DefaultClientResources clientResources = DefaultClientResources.create();
clientResources.eventBus().get().subscribe(e -> System.out.println("event: " + e));
LettuceClientConfiguration clientConfig = LettuceClientConfiguration
.builder()
.clientResources(clientResources)
.build();