I have initialized the Spring Boot app with Lettuce(io.lettuce.core.api) configuration like this
@Configuration
class RedisConfiguration {
@Value("${spring.redis.host}")
private String redisHostname;
@Value("${spring.redis.port}")
private int redisPort;
private StatefulRedisConnection<String, String> redisConnection;
private static RedisClient redisClient;
@Bean
public RedisCommands connectionFactory() {
RedisURI redisURI = RedisURI.create(redisHostname,redisPort);
redisClient = RedisClient.create(redisURI);
redisConnection = redisClient.connect();
RedisCommands<String, String> syncCommands =
redisConnection.sync();
return syncCommands;
}
}
I want to call redisClient.shutdown();
when application shuts down or exits. What is the right place to terminate the redis connection ?