Skip to content
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

[#241] 랭킹에 로컬 캐시 적용 #244

Merged
merged 4 commits into from
Dec 1, 2023
Merged

[#241] 랭킹에 로컬 캐시 적용 #244

merged 4 commits into from
Dec 1, 2023

Conversation

charlesuu
Copy link
Collaborator

@charlesuu charlesuu commented Nov 29, 2023

관련 PR 목록

1. 크루 랭킹 기능
2. 랭킹에 로컬 캐시 적용
3. 크루 랭킹의 캐시 저장소 변경, 캐싱 스케줄러의 중복 실행 방지

👨‍💻 작업 사항

📑 PR 개요

  • 랭킹 조회 성능 개선을 위해 CaffeineCache를 활용한 로컬 캐싱 적용
  • 랭킹 캐시의 갱신 작업을 수행하는 스케줄러 구현

✅ 작업 목록

  • 랭킹 조회 성능 개선을 위해 CaffeineCache를 활용한 로컬 캐싱 적용
  • 랭킹 캐시의 갱신 작업을 수행하는 스케줄러 구현

📀 관련 데이터 (화면, 테이블, API 등)

화면

image

테이블 명

  • crew, member, game, crew_member, game_member

API endpoint

  • GET /ranking/crews

반환 예시

200 OK

[
  {
    "id": 14,
    "name": "노드크루",
    "memberCount": 10,
    "maxMemberCount": 15,
    "profileImageUrl": "pickpleCrewProfileImage.s3.ap-northeast-2.amazonaws.com",
    "addressDepth1": "서울시",
    "addressDepth2": "강남구",
    "crewActivityScore": 10000,
    "mannerScore": 10000,
    "totalScore": 20000,
    "rank": 1,
  },
  {
    "id": 9,
    "name": "하하크루",
    "memberCount": 3,
    "maxMemberCount": 10,
    "profileImageUrl": "pickpleCrewProfileImage.s3.ap-northeast-2.amazonaws.com",
    "addressDepth1": "서울시",
    "addressDepth2": "마포구",
    "crewActivityScore": 10000,
    "mannerScore": 5000,
    "totalScore": 15000,
    "rank": 2,
  },
  {
    "id": 142,
    "name": "룰루크루",
    "memberCount": 20,
    "maxMemberCount": 25,
    "profileImageUrl": "pickpleCrewProfileImage.s3.ap-northeast-2.amazonaws.com",
    "addressDepth1": "서울시",
    "addressDepth2": "동대문구",
    "crewActivityScore": 1000,
    "mannerScore": 5000,
    "totalScore": 6000,
    "rank": 3,
  },
  ...	
]

Prefix

PR 코멘트를 작성할 때 항상 Prefix를 붙여주세요.

  • P1: 꼭 반영해주세요 (Request changes)
  • P2: 적극적으로 고려해주세요 (Request changes)
  • P3: 웬만하면 반영해 주세요 (Comment)
  • P4: 반영해도 좋고 넘어가도 좋습니다 (Approve)
  • P5: 그냥 사소한 의견입니다 (Approve)

@charlesuu charlesuu added the 신규 기능 [feat] 새로운 기능을 추가한다. label Nov 29, 2023
@charlesuu charlesuu added this to the 6차 스프린트 milestone Nov 29, 2023
@charlesuu charlesuu self-assigned this Nov 29, 2023
@@ -9,9 +9,15 @@ public enum CacheType {

POLYGON("polygon", Integer.MAX_VALUE, 1000),
ADDRESS("address", Integer.MAX_VALUE, 1000),
RANKING("ranking", Constants.SIX_HOURS_IN_SECONDS, 10),
Copy link
Member

Choose a reason for hiding this comment

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

p2

마지막에 들어가는 10의 경우 Key와 Value로 이루어진 엔트리의 개수로 알고 있습니다! 현재 배포된 페이지에서는 Ranking에 나오는 Crew의 개수가 10개로 제한되어 있지는 않은 것 같은데 앞으로는 10개만 보여주는 것일까요?!

Copy link
Collaborator Author

@charlesuu charlesuu Nov 30, 2023

Choose a reason for hiding this comment

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

랭킹 캐시의 경우 하나의 Key에 List<RankingResponse>의 형태로 모든 랭킹 정보를 담고 있습니다. 크루 랭킹의 경우 crew라는 Key에 List<CrewRankingResponse>를 담고 있는데요. 따라서 마지막 값을 10으로 설정해도 모든 크루 랭킹 정보를 저장할 수 있습니다.👍👍
사실 마지막 값을 1로 설정해도 정상적으로 동작하는 상황이기에 값을 어떻게 설정하는 것이 좋을지 고민이 되었는데요. 향후 멤버 랭킹, 경기 랭킹 등이 추가될 것을 대비해서 10정도로 설정해보았습니다.😁😀😊

Copy link
Member

Choose a reason for hiding this comment

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

아하 리스트군요~! 감사합니다! ㅎㅎ

Comment on lines 28 to 29
List<CrewRankingResponse> crewRankings = rankingJdbcRepository.getCrewRankings();
System.out.println(crewRankings.size() + "개의 크루 랭킹 갱신");
Copy link
Member

Choose a reason for hiding this comment

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

P1

  • 일단 crewRankings에 final 붙여야 할 것 같아요
  • sout 보다는 log로 남기는게 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

적용 커밋 : 137393c

  • final 삽입하였습니다. 꼼꼼한 리뷰 감사합니다~~😊😊
  • sout은 캐싱이 잘 동작하는지 확인해보기 위해 개인 디버깅 용도로 붙여두었던 것인데 실수로 커밋에 포함시켰네요ㅜㅜ. 해당 라인 삭제하였습니다. 감사합니다~👍👍

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

28.6% 28.6% Coverage
0.0% 0.0% Duplication

@charlesuu charlesuu merged commit b5840c6 into dev Dec 1, 2023
3 checks passed
@charlesuu charlesuu deleted the feature/#241 branch December 1, 2023 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
신규 기능 [feat] 새로운 기능을 추가한다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants