How can I configure the socket option "keepalive" for Jedis client while using Redis database?

Viewed 11

I want to configure my client's socket options as in the following example which is created for Lettuce. Is there a way to make it in Jedis?

@Bean
public LettucePoolingClientConfiguration lettucePoolConfig() {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMaxIdle(poolMaxIdle);
    poolConfig.setMinIdle(poolMinIdle);
    poolConfig.setMaxTotal(poolMaxActive);

    SocketOptions socketOptions = SocketOptions.builder().keepAlive(
            SocketOptions.KeepAliveOptions.builder()
                    .enable(true)
                    .idle(Duration.ofMinutes(3))
                    .count(3)
                    .interval(Duration.ofSeconds(10))
                    .build()).build();

    ClientOptions clientOptions = ClientOptions.builder()
            .socketOptions(socketOptions)
            .build();

    return LettucePoolingClientConfiguration.builder()
            .poolConfig(poolConfig)
            .readFrom(ReadFrom.MASTER)
            .clientOptions(clientOptions)
            .build();
}
0 Answers
Related