documentItem->isGranted() 결과를 캐싱하여 불필요한 중복 쿼리 방지#1964
Merged
1 commit merged intoFeb 22, 2017
Merged
Conversation
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
게시판 스킨에 따라 차이는 있지만, 댓글이 많은 문서를 열람하면
documentItem->isGranted()메소드가 댓글 숫자만큼 호출되는 경우를 종종 봅니다. 그 밖에도 위젯 등에서 많이 호출하는 메소드이다 보니 한 페이지를 로딩하는 데 수십 번씩 호출되는 일이 드물지 않습니다.관리자와 손님은 간단하게 처리되지만, 일반 회원은 매번 아래의 코드가 실행됩니다.
일단 저렇게 모듈 모델로 넘어가면 연쇄작용으로 더 많은 메소드들이 호출되고, DB와 캐시에 엄청나게 많은 요청이 발생합니다. 한 요청 내에서 같은 문서에 대한 같은 회원의 권한이 바뀔 리가 없는데 말이죠...
이 PR에서는
documentItem클래스 내에서isGranted()메소드의 결과를 캐싱하도록 하여, 한 요청 내에서 같은 문서에 대해서는 한 번만 쿼리가 발생하도록 합니다. 장기간 캐싱하지 않으므로 부작용은 거의 없을 것으로 보입니다. 또한 세션 변수 체크를 캐시 체크 앞에 배치하여, 서드파티 자료가 기존 방식대로 세션 변수를 조작한 경우 캐시보다 앞서 적용되도록 했습니다.