Skip to content

[23기_임종훈] 캐싱&로깅 미션 제출합니다.#57

Merged
Hoyoung027 merged 6 commits into
CEOS-Developers:Jong0128from
Jong0128:Jong0128
May 18, 2026
Merged

[23기_임종훈] 캐싱&로깅 미션 제출합니다.#57
Hoyoung027 merged 6 commits into
CEOS-Developers:Jong0128from
Jong0128:Jong0128

Conversation

@Jong0128

Copy link
Copy Markdown

No description provided.

@gitaehee

Copy link
Copy Markdown

이번주도 과제하시느라 수고많으셨습니다!!

@whc9999 whc9999 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

리뷰 완료했습니다! 과제 하시느라 수고 많으셨어요~

Comment thread docker-compose.yml
Comment on lines 5 to 11
env_file:
- .env
environment:
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-prod}
SPRING_PROFILES_ACTIVE: prod
ports:
- "8080:8080"
restart: unless-stopped

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

prod 프로필로 앱만 띄우고 Redis 컨테이너나 Redis host 환경변수를 주입하지 않는데요, RedisCacheConfig가 항상 RedisCacheManager를 등록하므로, @Cacheable이 붙은 api는 기본 Redis 주소로 접근하게 됩 듯 합니다. EC2 컨테이너 안에 Redis가 없으면 첫 조회부터 Redis connection failure로 api가 실패할 수 있을 것 같습니다. prod에도 Redis 설정을 넣거나, compose에 Redis를 추가하거나, 캐시 장애 시 DB fallback용 CacheErrorHandler가 필요할 것 같습니다!

Comment on lines 23 to 29
private final TheaterRepository theaterRepository;
private final ScheduleRepository scheduleRepository;

@Cacheable(value = "schedules", key = "#movieId + ':' + #theaterId")
@Transactional(readOnly = true)
public List<ScheduleResponse> getSchedule(Long movieId, Long theaterId) {
validateMovieAndTheater(movieId, theaterId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

movieId:theaterId 기준으로 스케줄을 캐시하지만, 스케줄 생성, 수정, 삭제 시 schedules 캐시를 비우는 코드가 없네요. 캐시된 스케줄이 상영 시간표 변경 후에도 최대 5분간 stale 상태로 남으니 관리자가 스케줄을 바꾼 직후 사용자가 사라진 시간표를 보고 예매를 시도할 수 있을 것 같습니다. 스케줄 write 경로에 @CacheEvict(value = "schedules", allEntries = true) 같은 무효화를 추가하는건 어떨까용

Comment on lines 21 to 26
// 영화 상세 조회
@Cacheable(value = "movieDetail", key = "#movieId")
@Transactional(readOnly = true)
public MovieResponse getMovie(Long id) {
Movie movie = movieRepository.findById(id)
public MovieResponse getMovie(Long movieId) {
Movie movie = movieRepository.findById(movieId)
.orElseThrow(() -> new CustomException(ErrorCode.MOVIE_NOT_FOUND));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

reservationRate, totalViewers, eggRate가 포함된 MovieResponse를 10분간 캐시하는데요, 예매나 리뷰, 통계 갱신이 발생해도 캐시 무효화가 없어서 영화 상세의 예매율이나 에그지수가 늦게 반영됩니다. 통계 필드를 캐시 응답에서 분리하거나 write 경로에서 evict하는 정책이 있으면 더 안전할 것 같네요!

Comment on lines 41 to 44
if (!passwordEncoder.matches(request.getPassword(), user.getPassword())) {
auditLog.warn("로그인 실패 user_id={} email={} 사유=비밀번호_불일치", user.getId(), user.getEmail());
throw new CustomException(ErrorCode.INVALID_PASSWORD);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

로그인이랑 회원가입 실패 시 감사 로그에 이메일이 평문으로 남는 것 같은데요, 감사 로그는 보관 기간이 길고, 접근 대상이 넓어질 수 있어서 개인정보 노출의 가능성이 있어 보입니다! 이메일은 마스킹 또는 해시 처리하는게 어떨까요?

@Hoyoung027 Hoyoung027 merged commit 7dd24fb into CEOS-Developers:Jong0128 May 18, 2026
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.

4 participants