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

#508 [feat] 글모임 best 글/ 작가 반환 로직 구현 #509

Merged
merged 16 commits into from
Sep 8, 2024

Conversation

sohyundoh
Copy link
Member

@sohyundoh sohyundoh commented Sep 4, 2024

✒️ 관련 이슈번호

Key Changes 🔑

  1. 회의 때 말씀드렸다시피 매 월요일에 자동 갱신이 아닌 일요일 -> 월요일 자정에 모든 정보를 삭제 하고 첫 번쨰 조회시 등록하는 방법으로 진행했습니다.
  2. 이 정보는 일주일 동안 변하지 않기 때문에 캐시 전략을 사용해 캐시를 반영하였습니다!

To Reviewers 📢

  • 작업 단위가 커스 커밋 메시지 기준으로 보는게 편할 것 같습니다!

필명 이름 만들어주는 기능은 이제 사용하지 않기 때문에 삭제했습니다
Curious Repository에서 curious를 오늘부터 7일 전 까지 생성된 curious값을 바탕으로 Post, count를 추출하여 리턴하는 로직을 작성했습니다.
일주일마다 MoimPopularInfo 를 삭제하고 첫 번째 조회에서, 새롭게 만드는 방식으로 구현했습니다. Map<WriterName, Int> 를 사용해서 저장해뒀던 객체에서 작가와 궁금해요 count를 꺼내 상위 작가만 리턴했습니다.
만일 이번 주 궁금해요 top 2 컨텐츠가 부족하다면, 기존의 글/ 작가의 total Curious Count에서 받아오는 것을 추가하도록 했습니다.
Top 2 를 궁금해요 생성 시점을 기준으로 채우는 방식으로 변경
@sohyundoh sohyundoh self-assigned this Sep 4, 2024
캐싱 관련해서 구현하면서 테스트 범위가 크지 않다고 판단하여 삭제했습니다
Caffeine 캐시를 사용하였는데, (EhCache보다 사용하기 쉬움) 이는 Scheduling이 되지 않아서 스케줄러를 직접 등록해야하기 때문에 스케줄러를 직접 등록했습니다. 스케줄러가 스레드를 잡아먹어서 이에 대해 방법을 고민해보겠습니다!
Copy link
Contributor

@parkheeddong parkheeddong left a comment

Choose a reason for hiding this comment

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

L.G.T.M. 너무 고생하셨습니다!!
캐시전략까지.. 배워가는게 정말 많은 코드였네요👍 궁금한 부분들이 있어서 적어두었씁니다!


private Caffeine<Object, Object> caffeineConfig() {
return Caffeine.newBuilder()
.maximumSize(200)
Copy link
Contributor

Choose a reason for hiding this comment

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

P5) 캐시 최대 크기를 200으로 설정하신 이유가 있는지 궁금해요!

Copy link
Member Author

Choose a reason for hiding this comment

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

현재는 글 모임이 많이 존재하지 않는 상황이기 때문에 캐시 최대 크기를 설정하는데 큰 의미를 두지는 않았습니다! 하지만 아래 보시는 것 처럼 현재 Limit에 비해 Memory 사용률이 적기도 하고, 200개를 캐싱할 경우 약 70KB (약 0.0001 MiB)를 사용하게 되기 때문에 확장성을 위해 크게 설정하였습니다!
image

private Caffeine<Object, Object> caffeineConfig() {
return Caffeine.newBuilder()
.maximumSize(200)
.expireAfterAccess(5, TimeUnit.DAYS)
Copy link
Contributor

Choose a reason for hiding this comment

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

P5) 7일간 캐시에 남아있는 데이터가 모두 유효해야 하는 것으로 이해했는데 ExpireAfterAccess 를 설정하신 이유가 궁금합니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

첫 번째 조회할 때 기록이 만들어지는데, 그게 월요일이라는 보장이 없었습니다! 그래서 7일보다 짧은 5일로 설정하였고, 만일 업데이트 된다면 그 순간 부터 5일 연장이므로 5일도 충분하다고 생각했습니다!

ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
Scheduler scheduler;
scheduler = Scheduler.forScheduledExecutorService(executor);
return scheduler;
Copy link
Contributor

Choose a reason for hiding this comment

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

P5) Executors.newSingleThreadScheduledExecutor() 대신, Executors.newScheduledThreadPool 로 비동기적으로 처리해서 말씀하신 스레드 문제를 해결하는 건 어떨까요??

Copy link
Member Author

Choose a reason for hiding this comment

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

죻습니다!! 감사합니다! 스레드풀로 약 5개 정도 사용하면 될 것 같습니다!

@sohyundoh sohyundoh merged commit 56e4b39 into develop Sep 8, 2024
1 check passed
@sohyundoh sohyundoh deleted the feat/#508 branch September 8, 2024 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] 매주 월요일 업데이트 항목 반영
2 participants