Spring boot RedisCluster Configuration
@Configuration
public class RedisConfiguration {
@Value("${spring.redis.host}")
private String redisHost;
@Value("${spring.redis.port}")
private int redisPort;
@Bean(destroyMethod = "shutdown")
public ClientResources clientResources() {
return DefaultClientResources.create();
}
@Bean(destroyMethod = "shutdown")
public RedisClusterClient redisClient(ClientResources clientResources) {
return RedisClusterClient.create(clientResources, RedisURI.create(redisHost, redisPort));
}
@Bean(destroyMethod = "close")
public StatefulRedisClusterConnection connection(RedisClusterClient redisClient) {
return redisClient.connect();
}
@Bean
public RedisAdvancedClusterCommands redisCommands(StatefulRedisClusterConnection connection) {
return connection.sync();
}
}
댓글
댓글 쓰기