Skip to content
Open
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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.security:spring-security-crypto'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
implementation 'me.paulschwarz:spring-dotenv:4.0.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.creditto.core_banking.global.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
public class RedisConfig {

@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);

// key:value
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());

// hash key:value
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer((new GenericJackson2JsonRedisSerializer()));

return template;
}
}
5 changes: 5 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ spring:
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
host: localhost
port: 6379
Comment on lines +11 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Redis ν˜ΈμŠ€νŠΈμ™€ ν¬νŠΈκ°€ localhost와 6379둜 ν•˜λ“œμ½”λ”©λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μ΄λ ‡κ²Œ ν•˜λ©΄ 개발, μŠ€ν…Œμ΄μ§•, ν”„λ‘œλ•μ…˜ λ“± λ‹€μ–‘ν•œ ν™˜κ²½μ— 배포할 λ•Œ 섀정을 λ³€κ²½ν•˜κΈ° μ–΄λ ΅μŠ΅λ‹ˆλ‹€. λ°μ΄ν„°λ² μ΄μŠ€ μ„€μ •μ²˜λŸΌ ν™˜κ²½ λ³€μˆ˜λ₯Ό μ‚¬μš©ν•˜κ³  둜컬 κ°œλ°œμ„ μœ„ν•œ 기본값을 μ œκ³΅ν•˜λŠ” 방식을 μ‚¬μš©ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

      host: ${REDIS_HOST:localhost}
      port: ${REDIS_PORT:6379}

timeout: 2000

scheduler:
remittance:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.creditto.core_banking.domain.redis;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

@Disabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

@Disabled μ–΄λ…Έν…Œμ΄μ…˜μœΌλ‘œ 인해 ν…ŒμŠ€νŠΈ ν΄λž˜μŠ€κ°€ λΉ„ν™œμ„±ν™”λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. λΉ„ν™œμ„±ν™”λœ ν…ŒμŠ€νŠΈλŠ” μ‹€ν–‰λ˜μ§€ μ•ŠμœΌλ―€λ‘œ μ½”λ“œ ν’ˆμ§ˆμ„ 보μž₯ν•˜κ±°λ‚˜ νšŒκ·€λ₯Ό λ°©μ§€ν•˜λŠ” 데 μ•„λ¬΄λŸ° 도움이 λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. λ§Œμ•½ μ‹€ν–‰ 쀑인 Redis μΈμŠ€ν„΄μŠ€κ°€ ν•„μš”ν•΄μ„œ λΉ„ν™œμ„±ν™”ν–ˆλ‹€λ©΄, κ·Έ 이유λ₯Ό μ£Όμ„μœΌλ‘œ λͺ…μ‹œν•˜κ³  CI/CD νŒŒμ΄ν”„λΌμΈμ—μ„œ νŠΉμ • μ‘°κ±΄μ—μ„œλ§Œ μ‹€ν–‰λ˜λ„λ‘ (예: @Tagλ‚˜ Spring Profile μ‚¬μš©) κ΅¬μ„±ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. μ§€κΈˆ λ‹Ήμž₯ μ‹€ν–‰ν•  수 μ—†λŠ” ν…ŒμŠ€νŠΈλΌλ©΄ PR에 ν¬ν•¨ν•˜μ§€ μ•ŠλŠ” 것도 λ°©λ²•μž…λ‹ˆλ‹€. μš°μ„ μ€ 이 ν…ŒμŠ€νŠΈκ°€ μ‹€ν–‰λ˜λ„λ‘ @Disabledλ₯Ό μ œκ±°ν•˜λŠ” 것을 ꢌμž₯ν•©λ‹ˆλ‹€.

@SpringBootTest
public class RedisTest {

@Autowired
private RedisTemplate<String, Object> redisTemplate;

@Test
void testRedisConnection() {
String key = "test-key";
String expectedValue = "redis";
redisTemplate.opsForValue().set(key, expectedValue);
Object value = redisTemplate.opsForValue().get(key);
System.out.println("Redis Value: " + value);
}
}