Skip to content

Commit

Permalink
cache key 중복으로 대기열 key 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
punkryn committed May 19, 2024
1 parent 5503451 commit 0f18aea
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ class GetRankAndTokenUseCase @Autowired constructor(private val redisTemplate: R
override fun getRankAndToken(dto: GetRankAndTokenCommandDto): Mono<GetRankAndTokenResultDto> {
val currentTime = dto.entryTime
val token = generateToken(dto.email, dto.ticketingId)
val key = "queue::${dto.ticketingId}"

val validateResult = validateSalePeriod(dto.ticketingId, currentTime)
val mono = validateResult.flatMap { _ ->
redisTemplate.opsForZSet().rank(dto.ticketingId.toString(), token)
redisTemplate.opsForZSet().rank(key, token)
.switchIfEmpty(
redisTemplate.opsForZSet().add(dto.ticketingId.toString(), token, currentTime.toDouble())
.then(redisTemplate.opsForZSet().rank(dto.ticketingId.toString(), token))
redisTemplate.opsForZSet().add(key, token, currentTime.toDouble())
.then(redisTemplate.opsForZSet().rank(key, token))
)
}

Expand Down

0 comments on commit 0f18aea

Please sign in to comment.