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

[member-service] Redis config #52

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions module-redis/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.redisson:redisson-spring-boot-starter:3.17.4'
api ('org.springframework.boot:spring-boot-starter-data-redis')
api ('org.redisson:redisson-spring-boot-starter:3.17.4')
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;

import java.time.Duration;

@Component
public class RedisConfig {

public static RedisConnectionFactory createRedisConnectionFactory(String host, int port) {
return new LettuceConnectionFactory(host, port);
}

public static CacheManager createCacheManager(RedisConnectionFactory redisConnectionFactory) {
RedisCacheManager.RedisCacheManagerBuilder builder = RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(redisConnectionFactory);
RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig()
Expand Down
1 change: 1 addition & 0 deletions service-member/module-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
dependencies {
implementation project(':service-member:module-core')
implementation project(':service-member:module-batch')
implementation project(':module-redis')
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.cloud:spring-cloud-starter-vault-config'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.github.msafriends.moduleapi.config;

import com.github.msafriends.moduleredis.config.RedissonConfig;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;

@Configuration
@EnableCaching
public class RedisConfig {

@Value("${spring.data.redis.host}")
private String host;

@Value("${spring.data.redis.port}")
private int port;

@Bean
public RedissonClient redissonClient() {
return RedissonConfig.createRedissonClient(host, port);
}

@Bean
public RedisConnectionFactory redisConnectionFactory() {
return com.github.msafriends.moduleredis.config.RedisConfig.createRedisConnectionFactory(host, port);
}

@Bean
public CacheManager cacheManager() {
return com.github.msafriends.moduleredis.config.RedisConfig.createCacheManager(redisConnectionFactory());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.msafriends.moduleapi.config;

import com.github.msafriends.moduleapi.service.MemberCouponService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class RedissonLockCouponClient {
private final RedissonClient redissonClient;
private final MemberCouponService memberCouponService;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ spring:
ddl-auto: update
properties:
hibernate:
# globally_quoted_identifiers: true
# globally_quoted_identifiers_skip_column_definitions: true
show_sql: true
format_sql:
defer-datasource-initialization: true
Expand All @@ -31,6 +29,11 @@ spring:
vault:
enabled: false

data:
redis:
port: 6379
host: 127.0.0.1

logging:
level:
org.hibernate.SQL: debug
Expand Down