-
Notifications
You must be signed in to change notification settings - Fork 1
[#23] pg수수료 ApplicationStartedEvent 로컬캐싱 전환 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| private String buildRouteKey(PayMethod payMethod, PayProvider payProvider) { | ||
| return ROUTE_KEY_PREFIX + payMethod.name() + ":" + payProvider.name(); | ||
| } | ||
| } |
There was a problem hiding this comment.
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(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PaymentPgRouter 단위테스트 입니다
PaymentPgRouter 생성자에서 pg구현체 list 를 받고있어서 mock 데이터로 직접 생성했습니다.
| } | ||
| ); | ||
|
|
||
| application.run(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ApplicationStartedEvent 로 db조회해서 수수료를 로컬캐시 pgFeeCache에 저장하고 있습니다.
런타임 전에 완료되는 것을 검증해봤습니다.
(pgFeeCache 가 private 라서 주석으로 커밋했습니다.)
| @EventListener(ApplicationStartedEvent.class) | ||
| public void initPgCache() { | ||
| setPgFeeCache(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostConstruct 는 싱글톤 생성 락에서 실행되어, 외부bean작업 포함되는게 좋지 않다고해서
ApplicationStartedEvent 시에 초기화하는 방향으로 수정해봤습니다.
| @Scheduled(cron = "0 * * * * *") | ||
| private void refreshPgCache() { | ||
| setPgFeeCache(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수수료 로컬캐시를 매일 0시에 업데이트 되는 코드를 추가했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-lab-lyan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다. 👍
3.매일 0시에 수수료정보 refresh