Skip to content

Commit

Permalink
♻️ : "Redis" 에러 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
imenuuu committed Sep 3, 2023
1 parent 965ce48 commit 6f30814
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/com/example/runway/config/RedisConfig.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.example.runway.config;

import io.lettuce.core.ClientOptions;
import io.lettuce.core.SocketOptions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisClusterConfiguration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.time.Duration;

@Configuration
@EnableRedisRepositories
public class RedisConfig {
Expand All @@ -20,8 +26,15 @@ public class RedisConfig {

@Bean
public RedisConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory(host, port);
}
RedisClusterConfiguration clusterConfiguration = new RedisClusterConfiguration();
clusterConfiguration.clusterNode(host, port);
LettuceClientConfiguration clientConfiguration = LettuceClientConfiguration.builder()
.clientOptions(ClientOptions.builder()
.socketOptions(SocketOptions.builder()
.connectTimeout(Duration.ofMillis(1000L)).build())
.build())
.commandTimeout(Duration.ofSeconds(1000L)).build();
return new LettuceConnectionFactory(clusterConfiguration, clientConfiguration); }

@Bean
public RedisTemplate<String, String> redisTemplate() {
Expand Down

0 comments on commit 6f30814

Please sign in to comment.