From 5b614ca0f9cdc403bf0cdc69585a87308a6a114b Mon Sep 17 00:00:00 2001 From: sunwoong Date: Mon, 14 Oct 2024 17:23:32 +0900 Subject: [PATCH] =?UTF-8?q?DRAW-375=20refactor:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/com/xorker/draw/lock/RedisLockAdapter.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/adapter/redis/src/main/kotlin/com/xorker/draw/lock/RedisLockAdapter.kt b/adapter/redis/src/main/kotlin/com/xorker/draw/lock/RedisLockAdapter.kt index 33441b76..e61e3025 100644 --- a/adapter/redis/src/main/kotlin/com/xorker/draw/lock/RedisLockAdapter.kt +++ b/adapter/redis/src/main/kotlin/com/xorker/draw/lock/RedisLockAdapter.kt @@ -14,7 +14,7 @@ internal class RedisLockAdapter( override fun lock(key: String) { while (getLock(key).not()) { try { - Thread.sleep(50) + Thread.sleep(SLEEP_TIME) } catch (e: InterruptedException) { throw UnSupportedException } @@ -28,10 +28,12 @@ internal class RedisLockAdapter( private fun getLock(key: String): Boolean { return redisTemplate .opsForValue() - .setIfAbsent(key + LOCK, LOCK, Duration.ofSeconds(1)) ?: throw NotFoundLockKeyException + .setIfAbsent(key + LOCK, LOCK, Duration.ofSeconds(LOCK_TIME)) ?: throw NotFoundLockKeyException } companion object { private const val LOCK = "lock" + private const val LOCK_TIME = 1L + private const val SLEEP_TIME = 50L } }