Skip to content

Conversation

@jiwon1217
Copy link
Collaborator

🛰️ Issue Number

🪐 작업 내용

  • 마이페이지 조회 기능을 구현했습니다.
  • Redis를 먼저 조회하고, Redis에 데이터가 없을 경우 MySQL을 조회하는 방식으로 구현했습니다.
@Override
    public MyPage getMyPageByUserId(long userId) {
        try {
            return redisRepository.getStatByUserId(userId);
        } catch (Exception e) {
            log.error("Redis miss, fallback to MySQL for userId={}", userId, e);
        }

        StatWithNicknameAndUserId stat = findFirstMatchingStat(userId);
        long rank = jpaRepository.countByScoreGreaterThan(stat.score()) + 1;

        return new MyPage(
            stat.nickname(),
            rank,
            stat.totalGames(),
            stat.winningGames(),
            stat.score()
        );
    }

📚 Reference

✅ Check List

  • 코드가 정상적으로 컴파일되나요?
  • 테스트 코드를 통과했나요?
  • merge할 브랜치의 위치를 확인했나요?
  • Label을 지정했나요?

@jiwon1217 jiwon1217 self-assigned this Jul 25, 2025
@jiwon1217 jiwon1217 added the enhancement New feature or request label Jul 25, 2025
Map<Object, Object> statMap = hashOps.entries(statUserKey);

if (rank == null || score == null || statMap.isEmpty()) {
throw new IllegalStateException("User not found in Redis: " + userId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

왜 여기는 customException을 쓰지 않으신건지 궁금합니다!

Copy link
Collaborator Author

@jiwon1217 jiwon1217 Jul 25, 2025

Choose a reason for hiding this comment

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

구조가 Redis 조회 -> 없으면 -> MySQL 조회로 넘어가게 되는데, 위 코드에서 던진 예외를 아래의 코드로 처리를 합니다. 그래서 해당 예외는 프론트로 내려가지 않기 때문에 CustomException 처리를 하지 않았습니다 !

try {
            return redisRepository.getStatByUserId(userId);
        } catch (Exception e) {
            log.error("Redis miss, fallback to MySQL for userId={}", userId, e);
        }

Copy link
Collaborator

@sehee123 sehee123 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다! 🚌

Copy link
Collaborator

@LimKangHyun LimKangHyun left a comment

Choose a reason for hiding this comment

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

다른 분들이 리뷰를 꼼꼼하게 해주셨네요! 고생하셨습니다!

Copy link
Collaborator

@silver-eunjoo silver-eunjoo left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 !! :)

@jiwon1217 jiwon1217 merged commit a178fe1 into dev Jul 25, 2025
2 of 4 checks passed
@jiwon1217 jiwon1217 deleted the feat/106 branch July 25, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants