Skip to content

Comments

[BE] 동시성 수정 및 Redis 캐시 사용#324

Open
soyun-i wants to merge 15 commits intodevelopfrom
be/feat/317
Open

[BE] 동시성 수정 및 Redis 캐시 사용#324
soyun-i wants to merge 15 commits intodevelopfrom
be/feat/317

Conversation

@soyun-i
Copy link
Contributor

@soyun-i soyun-i commented May 11, 2025


🚀 어떤 기능을 구현했나요 ?

  • Redis를 활용한 분산 재고 관리 시스템
  • 주문 생성 시 원자적 재고 차감 및 동기화
  • 비동기 재고 동기화 처리(Reids와 DB)

🔥 어떤 문제를 마주했나요 ?

  • Redis와 DB간 데이터 일관성 유지 문제
  • 재고 캐시 활용와 DB 동기화 문제

✨ 어떻게 해결했나요 ?

  • 비동기 처리를 통한 DB 동기화 및 성능 최적화!

📝 어떤 부분에 집중해서 리뷰해야 할까요?

  • AsyncConfig와 연계된 @async 메서드를 집중해서 봐주세요!

📚 참고 자료 및 회고

@soyun-i soyun-i added this to the 6차 마일스톤 milestone May 11, 2025
@soyun-i soyun-i self-assigned this May 11, 2025
}

public <T> T executeWithLock(String lockName, long waitTime, long leaseTime, Supplier<T> supplier) {
public <T> T executeWithLock(String lockName, long waitTime, long leaseTime, int retryCount, Supplier<T> supplier) {
Copy link
Contributor

Choose a reason for hiding this comment

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

제네릭을 사용하신 이유가 따로 있으신가요?

log.debug("락 얻기 시도 ({}/{}): {}", attempts + 1, retryCount, lockName);
isLocked = lock.tryLock(waitTime, leaseTime, TimeUnit.SECONDS);

if (!isLocked) {
Copy link
Contributor

Choose a reason for hiding this comment

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

락 얻기 실패했을경우 별도로 다른 처리가 필요 하지 않을까요?

try {
lock.unlock();
log.debug("락 해제: {}", lockName);
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

락 해제에 실패했을때도 별도의 처리가 있어야하지 않을까요?

private static final String STOCK_GLOBAL_LOCK = "global:stock:lock";
private static final int CACHE_TTL_HOURS = 72;

// Redis에서 재고 확인, 없으면 DB에서 조회하여 캐싱
Copy link
Contributor

Choose a reason for hiding this comment

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

왜 Redis를 이용한 분산 재고 처리를 하셨는지 궁금합니다

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.

2 participants