Skip to content

Conversation

@SinJeongEun
Copy link
Collaborator

@SinJeongEun SinJeongEun commented Nov 23, 2025

  1. pg수수료 redis zset 캐싱 -> 로컬캐싱
  2. pg health check 는 redis 유지
    3.매일 0시에 수수료정보 refresh

fix: pg수수료 redis zset 캐싱 -> 로컬캐싱
pg health check 는 redis 유지
@SinJeongEun SinJeongEun self-assigned this Nov 23, 2025
애플리케이션 실행 전 로컬케시 초기화 검증
private String buildRouteKey(PayMethod payMethod, PayProvider payProvider) {
return ROUTE_KEY_PREFIX + payMethod.name() + ":" + payProvider.name();
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@f-lab-lyan 🙂
redis 캐싱정보에서 수수료는 제외했습니다.
pg health 는 분산환경에서 실시간으로 모두 반영해야되는 정보라서 redis 에 유지했습니다!


// 캐시 초기화 @EventListener(ApplicationReadyEvent.class)
paymentPgRouter.initPgCache();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@f-lab-lyan 🙂

PaymentPgRouter 단위테스트 입니다
PaymentPgRouter 생성자에서 pg구현체 list 를 받고있어서 mock 데이터로 직접 생성했습니다.

}
);

application.run();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@f-lab-lyan 🙂

ApplicationStartedEvent 로 db조회해서 수수료를 로컬캐시 pgFeeCache에 저장하고 있습니다.
런타임 전에 완료되는 것을 검증해봤습니다.
(pgFeeCache 가 private 라서 주석으로 커밋했습니다.)

scheduling refreshPgCache 매일 0시
@EventListener(ApplicationStartedEvent.class)
public void initPgCache() {
setPgFeeCache();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@f-lab-lyan 🙂

PostConstruct 는 싱글톤 생성 락에서 실행되어, 외부bean작업 포함되는게 좋지 않다고해서
ApplicationStartedEvent 시에 초기화하는 방향으로 수정해봤습니다.

@Scheduled(cron = "0 * * * * *")
private void refreshPgCache() {
setPgFeeCache();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@f-lab-lyan 🙂

수수료 로컬캐시를 매일 0시에 업데이트 되는 코드를 추가했습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@SinJeongEun SinJeongEun linked an issue Nov 23, 2025 that may be closed by this pull request
Copy link
Collaborator

@f-lab-lyan f-lab-lyan left a comment

Choose a reason for hiding this comment

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

수고하셨습니다. 👍

@SinJeongEun SinJeongEun merged commit 3665e1e into main Dec 6, 2025
1 check 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.

Pg 라우팅 및 서버상태 캐싱

3 participants