Skip to content

Fix: 매장 캐시 표현식 수정#131

Merged
jaebeom79 merged 3 commits into
mainfrom
develop
Jun 3, 2026
Merged

Fix: 매장 캐시 표현식 수정#131
jaebeom79 merged 3 commits into
mainfrom
develop

Conversation

@jaebeom79

Copy link
Copy Markdown
Contributor

📢 기능 설명

필요시 실행결과 스크린샷 첨부

연결된 issue

연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.

close #{이슈넘버}

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 이슈넘버를 적었는가?

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the @Cacheable key generation logic in StoreService.java to handle null values for category and district enums using safe navigation and default values. The reviewer suggested extending the cache condition to also cover blank or empty name strings (#name.isBlank()) to improve cache efficiency.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

* Specification 사용으로 PostgreSQL+enum 조합에서 :param IS NULL 회피.
*/
@Cacheable(value = "storeList", key = "T(String).valueOf(#category) + ':' + T(String).valueOf(#district) + ':' + #page + ':' + #size", condition = "#name == null")
@Cacheable(value = "storeList", key = "(#category?.name() ?: 'ALL') + ':' + (#district?.name() ?: 'ALL') + ':' + #page + ':' + #size", condition = "#name == null")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

현재 getStores 메서드 내부에서는 name 파라미터가 null이거나 공백(isBlank())일 때 trimmedNamenull로 처리하여 이름 필터링 없이 조회를 수행합니다.

하지만 @Cacheablecondition#name == null로만 설정되어 있어, name이 빈 문자열("")이거나 공백으로만 이루어진 문자열(" ")일 경우 실제 쿼리는 이름 필터링 없이 동일하게 수행됨에도 불구하고 캐시를 타지 않고 매번 DB를 조회하게 됩니다.

캐시 효율성을 높이기 위해 condition 조건을 #name == null || #name.isBlank()로 수정하여 공백 문자열 입력 시에도 캐시가 적용되도록 개선하는 것을 추천합니다. SpEL의 || 연산자는 단락 평가(short-circuit evaluation)를 지원하므로 #namenull일 때 뒤의 isBlank()가 호출되지 않아 안전합니다.

Suggested change
@Cacheable(value = "storeList", key = "(#category?.name() ?: 'ALL') + ':' + (#district?.name() ?: 'ALL') + ':' + #page + ':' + #size", condition = "#name == null")
@Cacheable(value = "storeList", key = "(#category?.name() ?: 'ALL') + ':' + (#district?.name() ?: 'ALL') + ':' + #page + ':' + #size", condition = "#name == null || #name.isBlank()")

@jaebeom79 jaebeom79 merged commit a9c2124 into main Jun 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant