From e470e706123cd91968b4f77aa68df4658f5ab043 Mon Sep 17 00:00:00 2001 From: Klaus Date: Mon, 2 Dec 2024 08:40:38 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=98=88?= =?UTF-8?q?=EC=95=BD=20=EC=98=A4=ED=94=88=20=EC=84=A4=EC=A0=95=20-=20?= =?UTF-8?q?=EB=B6=84=EC=82=B0=EB=9D=BD=20=EC=A0=9C=EA=B1=B0,=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=EA=B0=80=20=EC=97=AC=EB=9F=AC=EB=8C=80=EB=9D=BC?= =?UTF-8?q?=EB=A9=B4=20=EC=97=AC=EB=9F=AC=EB=B2=88=20=ED=98=B8=EC=B6=9C?= =?UTF-8?q?=EB=90=A0=20=EC=88=98=20=EC=9E=88=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 1 - .../vividnext/sodalive/configs/RedisConfig.kt | 14 ------------- .../AudioContentReleaseSchedulerService.kt | 21 ++----------------- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2e02f9e..b0ee365 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,7 +34,6 @@ dependencies { implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("org.springframework.retry:spring-retry") implementation("org.jetbrains.kotlin:kotlin-reflect") - implementation("org.redisson:redisson-spring-boot-starter:3.17.7") // jwt implementation("io.jsonwebtoken:jjwt-api:0.11.5") diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt b/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt index 0e98856..09989bd 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/configs/RedisConfig.kt @@ -1,8 +1,5 @@ package kr.co.vividnext.sodalive.configs -import org.redisson.Redisson -import org.redisson.api.RedissonClient -import org.redisson.config.Config import org.springframework.beans.factory.annotation.Value import org.springframework.cache.annotation.EnableCaching import org.springframework.context.annotation.Bean @@ -29,17 +26,6 @@ class RedisConfig( @Value("\${spring.redis.port}") private val port: Int ) { - @Bean - fun redissonClient(): RedissonClient { - val config = Config() - config.useSingleServer() - .setAddress("redis://$host:$port") - .setConnectionMinimumIdleSize(1) // 최소 유휴 연결: 1 - .setConnectionPoolSize(5) // 최대 연결 풀 크기: 5 - - return Redisson.create(config) - } - @Bean fun redisConnectionFactory(): RedisConnectionFactory { val clientConfiguration = LettuceClientConfiguration.builder() diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/scheduler/AudioContentReleaseSchedulerService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/scheduler/AudioContentReleaseSchedulerService.kt index fdd62bd..a6b847f 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/scheduler/AudioContentReleaseSchedulerService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/scheduler/AudioContentReleaseSchedulerService.kt @@ -1,32 +1,15 @@ package kr.co.vividnext.sodalive.scheduler import kr.co.vividnext.sodalive.content.AudioContentService -import org.redisson.api.RedissonClient import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Service -import java.util.concurrent.TimeUnit @Service class AudioContentReleaseSchedulerService( - private val redissonClient: RedissonClient, private val audioContentService: AudioContentService ) { - @Scheduled(fixedRate = 1000 * 60 * 5) + @Scheduled(cron = "0 0/15 * * * *") fun release() { - val lock = redissonClient.getLock("lock:audioContentRelease") - - if (lock.tryLock(10, TimeUnit.SECONDS)) { - try { - println("락을 획득하여 배포를 시작합니다.") - audioContentService.releaseContent() - } finally { - if (lock.isHeldByCurrentThread) { - lock.unlock() - println("락 해제") - } - } - } else { - println("락을 획득하지 못해서 배포를 건너뜁니다") - } + audioContentService.releaseContent() } }