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

[Feat/#238] 데이터 베이스 케시 설정 #246

Merged
merged 12 commits into from
Jul 28, 2024
Merged

Conversation

belljun3395
Copy link
Collaborator

@belljun3395 belljun3395 commented Jul 23, 2024

🎫 연관 이슈

resolved: #238

💁‍♂️ PR 내용

  • 워크북 데이터 베이스 케시 설정

🙏 작업

  • SELECT_WORKBOOK_RECORD_CACHE 추가
  • SELECT_WRITER_CACHE 추가
  • selectWorkBook 메서드 캐시 설정
  • selectWriter 메서드, selectWriters 메서드 데이터 캐시 설정
  • 캐싱된 데이터 활용을 위한 XXXCacheManager 구현

🙈 PR 참고 사항

📸 스크린샷

selectWorkBook 캐시 확인

스크린샷 2024-07-23 오후 9 25 10

엔트리 사이즈 3으로 설정후 아이디 1 -> 2 -> 3 -> 4 -> 4 조회 결과

selectWriter 메서드, selectWriters 메서드 캐시 확인

아티클 조회시 selectWriter 수행됨
워크북 조회시 selectWriters 수행됨

워크북 1에 포함된 아티클 조회

스크린샷 2024-07-23 오후 10 10 22

selectWriter에서 캐시 저장

워크북 1 조회

스크린샷 2024-07-23 오후 10 10 40

selectWriters에서 캐시에 저장된 값 사용

🤖 테스트 체크리스트

  • 체크 미완료
  • 체크 완료

@github-actions github-actions bot added config 설정 파일과 관련된 내용을 다룰 때 사용됩니다 feature 새로운 기능을 만들 때 사용됩니다 labels Jul 23, 2024
@belljun3395 belljun3395 requested a review from hun-ca July 23, 2024 13:26
Copy link
Member

@hun-ca hun-ca left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 추가적으로 캐시 라이브러리를 호출하는 MemberCacheManager 코드에서 예외가 발생될 부분이 있는지 검토 부탁드립니다. 캐시 접근에 대한 예외가 API 실패로 연결되는건 바람직하지 않을것 같아서요

Comment on lines 62 to 64
Eh107Configuration.fromEhcacheCacheConfiguration(cache10ConfigurationBuilder)
val selectWorkBookRecordCacheConfig: javax.cache.configuration.Configuration<Any, Any> =
Eh107Configuration.fromEhcacheCacheConfiguration(cache10ConfigurationBuilder)
Copy link
Member

Choose a reason for hiding this comment

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

캐시 컨피그 객체는 공유해도 잘 동작하나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 런타임에 컨피그 객체를 수정하는 것이 없어 문제 없을 것 같습니다.

Comment on lines 58 to 59
.where(Member.MEMBER.ID.`in`(notCachedId))
.and(Member.MEMBER.TYPE_CD.eq(MemberType.WRITER.code))
Copy link
Member

Choose a reason for hiding this comment

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

.where(Member.MEMBER.ID.in(notCachedId)) 에서 충분히 작가가 필터링 될 수 있기 때문에 .and(Member.MEMBER.TYPE_CD.eq(MemberType.WRITER.code)) 는 생략해도 될 것 같아요. 안그래도 TYPE_CD에 인덱싱도 없을거 같구요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

selectWritersQueryExplain.txt

실행계획을 보면 Member.MEMBER.TYPE_CD.eq(MemberType.WRITER.code) 가 영향이 없어 보이는데 맞을까요..?

Copy link
Member

Choose a reason for hiding this comment

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

row가 적어서 실행계획이 크게 의미가 없긴 한데, 만약 로우가 엄청 많아질 때를 가정하면 TYPE_CD에 인덱스가 없어 필터 조건에 넣을지 고민해봐야 할거 같아요. 지금은 일단 이상없을거고 나중에 실행계획 보고 생각해보시죠

Comment on lines 48 to 49
val cachedId = cachedValues.map { it.writerId }
val notCachedId = query.writerIds.filter { it !in cachedId }
Copy link
Member

Choose a reason for hiding this comment

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

별건 아니지만 cachedId, notCachedId 변수는 복수형으로 바꾸는게 좋을거 같습니다. 딱 봤을때 컬렉션 타입인지 알 수 있어서요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

520898a 에서 수정하였습니다.

private val cacheManager: CacheManager,
) {

private var selectWriterCache: Cache<Any, Any> = cacheManager.getCache(SELECT_WRITER_CACHE)?.nativeCache as Cache<Any, Any>
Copy link
Member

Choose a reason for hiding this comment

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

호오옥시나 런타임 중에 cacheManager.getCache(SELECT_WRITER_CACHE)?.nativeCache 레퍼런스가 바뀌진 않겠죠?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

스크린샷 2024-07-25 오후 1 55 36

디컴파일 해보면 CacheMamager 생성 시점에 위의 코드가 실행되어서 문제 없을 것 같아요

Copy link
Member

Choose a reason for hiding this comment

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

오.. 굳잡

Copy link
Collaborator Author

@belljun3395 belljun3395 left a comment

Choose a reason for hiding this comment

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

리뷰 감사합니다!

Comment on lines 62 to 64
Eh107Configuration.fromEhcacheCacheConfiguration(cache10ConfigurationBuilder)
val selectWorkBookRecordCacheConfig: javax.cache.configuration.Configuration<Any, Any> =
Eh107Configuration.fromEhcacheCacheConfiguration(cache10ConfigurationBuilder)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 런타임에 컨피그 객체를 수정하는 것이 없어 문제 없을 것 같습니다.

private val cacheManager: CacheManager,
) {

private var selectWriterCache: Cache<Any, Any> = cacheManager.getCache(SELECT_WRITER_CACHE)?.nativeCache as Cache<Any, Any>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

스크린샷 2024-07-25 오후 1 55 36

디컴파일 해보면 CacheMamager 생성 시점에 위의 코드가 실행되어서 문제 없을 것 같아요

Comment on lines 48 to 49
val cachedId = cachedValues.map { it.writerId }
val notCachedId = query.writerIds.filter { it !in cachedId }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

520898a 에서 수정하였습니다.

Comment on lines 58 to 59
.where(Member.MEMBER.ID.`in`(notCachedId))
.and(Member.MEMBER.TYPE_CD.eq(MemberType.WRITER.code))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

selectWritersQueryExplain.txt

실행계획을 보면 Member.MEMBER.TYPE_CD.eq(MemberType.WRITER.code) 가 영향이 없어 보이는데 맞을까요..?

@belljun3395 belljun3395 force-pushed the main branch 2 times, most recently from dd1d3ad to 4d5a4bd Compare July 26, 2024 07:29
@belljun3395 belljun3395 force-pushed the feat/#238_belljun3395 branch from d38780d to 520898a Compare July 26, 2024 13:24
@belljun3395 belljun3395 merged commit b319fd0 into main Jul 28, 2024
5 checks passed
@belljun3395 belljun3395 changed the title [Feat/#238] 워크북 데이터 베이스 케시 설정 [Feat/#238] 데이터 베이스 케시 설정 Jul 30, 2024
@belljun3395 belljun3395 added the ⭐major⭐ 주요 이슈(추후 회고 및 복귀 시 참고용) label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config 설정 파일과 관련된 내용을 다룰 때 사용됩니다 feature 새로운 기능을 만들 때 사용됩니다 ⭐major⭐ 주요 이슈(추후 회고 및 복귀 시 참고용)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

워크북 데이터 베이스 케시 설정
2 participants