Repository navigation
[23기_김태익] 캐싱&로깅 미션 제출합니다. - #60
Conversation
| ports: | ||
| - "6379:6379" | ||
| restart: unless-stopped | ||
| command: redis-server --maxmemory 1gb --maxmemory-policy allkeys-lru --appendonly yes --activedefrag yes |
There was a problem hiding this comment.
docker-compose.yml에서 --maxmemory-policy allkeys-lru를 지정하여 메모리 초과 시 OOM 캐시 다운을 방지하고
--activedefrag yes 설정을 통해 캐시 삭제가 빈번할 때 발생하는 메모리 단편화 문제를 대응하신 점이 인상깊었습니다!
| try { | ||
| response = paymentClient.requestInstantPayment(paymentId, paymentRequest); | ||
| } catch (Exception e) { | ||
| log.error("외부 결제 API 호출 실패 (paymentId={}): {}", paymentId, e.getMessage(), e); |
There was a problem hiding this comment.
외부 API 호출 실패, 결제 금액 불일치 등 돈과 관련된 민감한 로직에 결제 ID 기대 금액, 실제 금액 등의 컨텍스트를 상세히 남겨주셨네욥 👍🏻
| - 사용자 요청이 있을 때마다, **매번 검증해야 하므로 조회 빈도 매우 빈번** | ||
| - 그때마다 별도의 외부 API로 Key 가져오면 응답 지연 및 호출 회수 초과 가능 | ||
|
|
||
| ### **2. 캐시 전략** |
There was a problem hiding this comment.
어떤 캐시 전략을 사용하셨는지 상세하게 적어주셔서 읽으며 도움이 많이 되었습니다~
| try { | ||
| paymentService.cancelPayment(paymentId); | ||
| } catch (Exception e) { | ||
| log.error("외부 결제 취소 실패 (paymentId={}): {}", paymentId, e.getMessage()); | ||
| } |
There was a problem hiding this comment.
catch 문 안에서 로깅만 하고 있어서 payment.cancelPayment(paymentId)에서 던져진 예외가 삼켜질 것 같습니다.
throw e 등을 통해 예외를 다시 던지면 좋을 것 같아요.
| --- | ||
| # 캐시 도입하기 | ||
|
|
||
| ## Redis 설정 |
There was a problem hiding this comment.
캐시 설정 이유와 어떤 전략을 사용했는지 자세히 설명해주셔서 많이 배워갑니다👍
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| @Configuration | ||
| public class RedisCacheConfig { |
There was a problem hiding this comment.
RedissonSpringCacheManager의 기본 직렬화를 사용하고 있는 것 같습니다.
기본 직렬화를 사용하게 되면 redis에 사람이 읽을 수 없는 바이너리 값이 들어가서 추후에 디버깅이 어려워질 것 같아요.
참고하시면 좋을 것 같은 자료 첨부합니다!
https://popo-se.tistory.com/28
https://zorba91.tistory.com/352
No description provided.