Skip to content

Commit

Permalink
DRAW-375 refactor: 코드 리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
SunwoongH committed Oct 14, 2024
1 parent b86761c commit 5b614ca
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
}

0 comments on commit 5b614ca

Please sign in to comment.