Skip to content

Conversation

@yuus95
Copy link
Collaborator

@yuus95 yuus95 commented May 3, 2025

작업 내용

  • 대기열 기능 구현

    • 예약하기 이전 사용자의 예약 유효기간 및, 선착순 기능을 제어하기 위해 필요한 대기열 등록 기능 구현
    • 해당 대기열에서 예약 가능한 순번에 도래했을 경우 예약이 가능
    • 해당 대기열에서 예약을 했을 경우 value삭제
    • 해당 대기열에서 시간이 만료됐을 경우 배치를 통하여 데이터 삭제
  • 예약 조회 기능 구현

  • 상점에서 일자별 예약 조회 기능 구현

  • 일자 별로 예약 가능한 리스트 조회 가능

구현 예정

  • 대기열 조회
  • 예약하기 기능 구현

@yuus95 yuus95 requested a review from f-lab-k May 3, 2025 03:40
@yuus95 yuus95 self-assigned this May 3, 2025
String storeReserveIdx,
String userIdx
) {
private static final String WAITING_KEY_FORMAT = "store:%s:waiting:%s";
Copy link

@f-lab-k f-lab-k May 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version 명도 입력하는게 좋을 것 같습니다~~
ex) v1처럼

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말씀해주신 부분이였는데 놓쳤네요..ㅜ
Value 구조가 달라진 경우를 대비할 수 있도록 버저닝을 추가했습니다!

}

public ReservesInDayDto getReservesInDay(Long storeIdx, LocalDate date) {
List<ReserveData> reserveDates = repository.findByStore_IdxAndReserveDate(storeIdx, date);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"_" 이것은 무엇인가요ㅎㅎ
의도한건가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메소드네이밍으로 함수 지을 때 _을 사용할 경우 연관관계 객체의 필드를 사용할 수 있는 것 같더라구요!
Property Expressions 관련 내용을 참고했습니다!
(https://docs.spring.io/spring-data/commons/reference/repositories/query-methods-details.html)

private final RedisTemplate<String, String> redisTemplate;

public void registerWaiting(StoreQueueDto storeQueueDto) {
redisTemplate.opsForZSet().add(storeQueueDto.key(), storeQueueDto.value(), storeQueueDto.score());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TTL은 안걸어도 될까요?
그리고 중복 체크도 해야하지 않을까 싶긴합니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마지막 등록 기준 7분을 유효기간으로 설정하도록 수정했습니다.
7분을 기준으로 잡은 이유는 마지막 대기열 기준으로 7분동안 대기 상태가 유지되기 떄문입니다.
마지막 요청 이후 키가 예약 요청이 없을 경우 대기열은 사라지고, 다시 예약 요청이 진행됐을 때 다시 생성되도록
TTL을 7분으로 주었습니다.

유저 idx의 존재유무에 따라 데이터를 적재할 수 있도록 putIfAbsent 메소드를 사용하도록 수정했습니다!
유저가 있는데 데이터를 삽입할려고 하면 false를 반환받아 에러를 던지도록 했습니다.

Copy link
Collaborator Author

@yuus95 yuus95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰해주셔서 감사합니다.
관련 내용 수정했습니다!

private final RedisTemplate<String, String> redisTemplate;

public void registerWaiting(StoreQueueDto storeQueueDto) {
redisTemplate.opsForZSet().add(storeQueueDto.key(), storeQueueDto.value(), storeQueueDto.score());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마지막 등록 기준 7분을 유효기간으로 설정하도록 수정했습니다.
7분을 기준으로 잡은 이유는 마지막 대기열 기준으로 7분동안 대기 상태가 유지되기 떄문입니다.
마지막 요청 이후 키가 예약 요청이 없을 경우 대기열은 사라지고, 다시 예약 요청이 진행됐을 때 다시 생성되도록
TTL을 7분으로 주었습니다.

유저 idx의 존재유무에 따라 데이터를 적재할 수 있도록 putIfAbsent 메소드를 사용하도록 수정했습니다!
유저가 있는데 데이터를 삽입할려고 하면 false를 반환받아 에러를 던지도록 했습니다.

String storeReserveIdx,
String userIdx
) {
private static final String WAITING_KEY_FORMAT = "store:%s:waiting:%s";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말씀해주신 부분이였는데 놓쳤네요..ㅜ
Value 구조가 달라진 경우를 대비할 수 있도록 버저닝을 추가했습니다!

}

public ReservesInDayDto getReservesInDay(Long storeIdx, LocalDate date) {
List<ReserveData> reserveDates = repository.findByStore_IdxAndReserveDate(storeIdx, date);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메소드네이밍으로 함수 지을 때 _을 사용할 경우 연관관계 객체의 필드를 사용할 수 있는 것 같더라구요!
Property Expressions 관련 내용을 참고했습니다!
(https://docs.spring.io/spring-data/commons/reference/repositories/query-methods-details.html)

@sonarqubecloud
Copy link

@yuus95 yuus95 merged commit 99ffc02 into main Jun 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants