From 5707d950c34fb16e3268bf4c6e1b77dc4f57de96 Mon Sep 17 00:00:00 2001 From: oereo Date: Thu, 7 Sep 2023 14:39:49 +0900 Subject: [PATCH 1/6] chore: redis config --- .../com/github/msafriends/moduleapi/config/RedisCache.java | 2 ++ .../module-api/src/main/resources/application-local.yml | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisCache.java diff --git a/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisCache.java b/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisCache.java new file mode 100644 index 00000000..17760660 --- /dev/null +++ b/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisCache.java @@ -0,0 +1,2 @@ +package com.github.msafriends.moduleapi.config;public class RedisCache { +} diff --git a/service-member/module-api/src/main/resources/application-local.yml b/service-member/module-api/src/main/resources/application-local.yml index ee4e415c..67046124 100644 --- a/service-member/module-api/src/main/resources/application-local.yml +++ b/service-member/module-api/src/main/resources/application-local.yml @@ -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 @@ -31,6 +29,11 @@ spring: vault: enabled: false + data: + redis: + port: 6379 + host: 127.0.0.1 + logging: level: org.hibernate.SQL: debug From e0104533d22aaa16c616d251af86e2593c0975a2 Mon Sep 17 00:00:00 2001 From: oereo Date: Thu, 7 Sep 2023 14:54:59 +0900 Subject: [PATCH 2/6] =?UTF-8?q?chore:=20redis=20dependency=20option?= =?UTF-8?q?=EC=9D=84=20api=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module-redis/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module-redis/build.gradle b/module-redis/build.gradle index 27a31b51..e1081e3f 100644 --- a/module-redis/build.gradle +++ b/module-redis/build.gradle @@ -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') } \ No newline at end of file From 38830353ab3cb5ea6505cced1c96e464901f11a2 Mon Sep 17 00:00:00 2001 From: oereo Date: Thu, 7 Sep 2023 14:55:22 +0900 Subject: [PATCH 3/6] =?UTF-8?q?chore:=20service-member=EC=97=90=EC=84=9C?= =?UTF-8?q?=20module-redis=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service-member/module-api/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/service-member/module-api/build.gradle b/service-member/module-api/build.gradle index ac9fd143..875df517 100644 --- a/service-member/module-api/build.gradle +++ b/service-member/module-api/build.gradle @@ -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' From 8112d72f1d38b504bbeaea7ecff84e5b45bcc2f0 Mon Sep 17 00:00:00 2001 From: oereo Date: Thu, 7 Sep 2023 14:55:52 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20RedisConfig=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moduleredis/config/RedisConfig.java | 3 -- .../moduleapi/config/RedisConfig.java | 36 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisConfig.java diff --git a/module-redis/src/main/java/com/github/msafriends/moduleredis/config/RedisConfig.java b/module-redis/src/main/java/com/github/msafriends/moduleredis/config/RedisConfig.java index 4af1be32..d1276117 100644 --- a/module-redis/src/main/java/com/github/msafriends/moduleredis/config/RedisConfig.java +++ b/module-redis/src/main/java/com/github/msafriends/moduleredis/config/RedisConfig.java @@ -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() diff --git a/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisConfig.java b/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisConfig.java new file mode 100644 index 00000000..fa2c3886 --- /dev/null +++ b/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisConfig.java @@ -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()); + } +} From 1e1477f9b730ea9fdf3027dfc0294bb82624b184 Mon Sep 17 00:00:00 2001 From: oereo Date: Thu, 7 Sep 2023 14:56:25 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20RedissonLockCouponClient=20basic=20?= =?UTF-8?q?template=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/RedissonLockCouponClient.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedissonLockCouponClient.java diff --git a/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedissonLockCouponClient.java b/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedissonLockCouponClient.java new file mode 100644 index 00000000..2f7a2ad0 --- /dev/null +++ b/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedissonLockCouponClient.java @@ -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; +} From f21b9147c2faa720e82b753ba7a10210a3149a77 Mon Sep 17 00:00:00 2001 From: oereo Date: Thu, 7 Sep 2023 14:56:50 +0900 Subject: [PATCH 6/6] =?UTF-8?q?remove:=20RedisCache=20class=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/github/msafriends/moduleapi/config/RedisCache.java | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisCache.java diff --git a/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisCache.java b/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisCache.java deleted file mode 100644 index 17760660..00000000 --- a/service-member/module-api/src/main/java/com/github/msafriends/moduleapi/config/RedisCache.java +++ /dev/null @@ -1,2 +0,0 @@ -package com.github.msafriends.moduleapi.config;public class RedisCache { -}