Skip to content

Commit

Permalink
fix: TicketSequence 구현 Deque로 동작하도록 변경
Browse files Browse the repository at this point in the history
seokjin8678 committed Jun 12, 2024
1 parent 6444b88 commit 7b43023
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public int reserve() {

@Override
public void cancel(int sequence) {
redisTemplate.opsForList().leftPush(key, String.valueOf(sequence));
redisTemplate.opsForList().rightPush(key, String.valueOf(sequence));
}

@Override
Original file line number Diff line number Diff line change
@@ -3,17 +3,17 @@
import com.festago.common.exception.BadRequestException;
import com.festago.common.exception.ErrorCode;
import com.festago.ticketing.domain.TicketSequence;
import java.util.Deque;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.stream.IntStream;

public class MemoryTicketSequence implements TicketSequence {

private final Queue<Integer> queue;
private final Deque<Integer> queue;

public MemoryTicketSequence(int quantity) {
this.queue = new ArrayBlockingQueue<>(quantity);
this.queue = new LinkedBlockingDeque<>(quantity);
List<Integer> sequences = IntStream.rangeClosed(1, quantity)
.boxed()
.toList();
@@ -36,7 +36,7 @@ public int reserve() {

@Override
public void cancel(int sequence) {
queue.offer(sequence);
queue.addFirst(sequence);
}

@Override

0 comments on commit 7b43023

Please sign in to comment.