Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting: 레디스 설정을 변경한다. #104

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend-config
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package com.thirdparty.ticketing.global.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
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.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import lombok.Setter;

@Configuration
@ConfigurationProperties(prefix = "spring.data.redis.lettuce")
@Setter
public class LettuceConfig {
private String host;
private Integer port;

@Bean
public LettuceConnectionFactory lettuceConnectionFactory() {
public LettuceConnectionFactory lettuceConnectionFactory(
@Value("${spring.data.redis.port}") int port,
@Value("${spring.data.redis.host}") String host) {
return new LettuceConnectionFactory(host, port);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import lombok.Setter;

@Configuration
@ConfigurationProperties(prefix = "spring.data.redis.redisson")
@Setter
public class RedissonConfig {
private String host;
private Integer port;

@Bean
public RedissonClient redissonClient() {
public RedissonClient redissonClient(
@Value("${spring.data.redis.port}") int port,
@Value("${spring.data.redis.host}") String host) {
Config config = new Config();
SingleServerConfig serverConfig = config.useSingleServer();
serverConfig.setAddress("redis://" + host + ":" + port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ public class TestContainerStarter {

@DynamicPropertySource
private static void registerRedisProperties(DynamicPropertyRegistry registry) {
registry.add("spring.data.redis.lettuce.host", REDIS::getHost);
registry.add(
"spring.data.redis.lettuce.port", () -> REDIS.getMappedPort(REDIS_PORT).toString());
registry.add("spring.data.redis.redisson.host", REDIS::getHost);
registry.add(
"spring.data.redis.redisson.port",
() -> REDIS.getMappedPort(REDIS_PORT).toString());
registry.add("spring.data.redis.host", REDIS::getHost);
registry.add("spring.data.redis.port", () -> REDIS.getMappedPort(REDIS_PORT).toString());
}
}
Loading