Conversation
- cached != null 체크를 cached != null && !cached.isEmpty()로 변경 - DB 조회 결과가 빈 배열인 경우 Redis에 저장하지 않도록 수정 - 카테고리/브랜드 전체 조회 API에서 빈 배열이 영구 캐싱되던 문제 해결 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WalkthroughBrandService와 CategoryService에 SLF4J 로깅을 추가하고, 캐시 검증 로직을 강화했습니다. 캐시된 데이터의 비어있음 여부를 확인하는 조건( Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/com/ongil/backend/domain/brand/service/BrandService.java (1)
56-66: 빈 데이터가 장기간 지속될 때 DB 재조회 부하는 운영적으로 보완 권장합니다.현재 구조에서는 실제 데이터가 비어 있는 동안 요청마다 DB를 조회합니다. 빈 결과 전용 키(또는 sentinel)를 짧은 TTL로만 저장하는 네거티브 캐시를 두면, 영구 빈 배열 캐싱은 피하면서도 DB 부하를 완화할 수 있습니다.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/ongil/backend/domain/brand/service/BrandService.java` around lines 56 - 66, The code currently skips caching when response.isEmpty(), causing repeated DB queries; update BrandService to write a negative cache entry when response is empty by calling redisCacheService.save with a distinct key or sentinel (e.g., CacheKeyConstants.BRANDS_ALL or a new CacheKeyConstants.BRANDS_ALL_EMPTY) and a short TTL (add a new CacheKeyConstants.BRANDS_ALL_EMPTY_TTL_HOURS or similar) instead of returning immediately; retain the existing positive caching via redisCacheService.save(CacheKeyConstants.BRANDS_ALL, response, CacheKeyConstants.MASTER_DATA_TTL_HOURS) for non-empty responses and ensure the lookup logic knows to treat the empty/sentinel key as an empty-result cache.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/main/java/com/ongil/backend/domain/brand/service/BrandService.java`:
- Around line 56-66: The code currently skips caching when response.isEmpty(),
causing repeated DB queries; update BrandService to write a negative cache entry
when response is empty by calling redisCacheService.save with a distinct key or
sentinel (e.g., CacheKeyConstants.BRANDS_ALL or a new
CacheKeyConstants.BRANDS_ALL_EMPTY) and a short TTL (add a new
CacheKeyConstants.BRANDS_ALL_EMPTY_TTL_HOURS or similar) instead of returning
immediately; retain the existing positive caching via
redisCacheService.save(CacheKeyConstants.BRANDS_ALL, response,
CacheKeyConstants.MASTER_DATA_TTL_HOURS) for non-empty responses and ensure the
lookup logic knows to treat the empty/sentinel key as an empty-result cache.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/com/ongil/backend/domain/brand/service/BrandService.javasrc/main/java/com/ongil/backend/domain/category/service/CategoryService.java
🔍️ 작업 내용
빈 배열 Redis 캐싱 방지
✨ 상세 설명
운영 스웨거에서 브랜드, 카테고리 조회시 빈배열 반환할 경우가 많았습니다. 이를 해결하기 위해 아래처럼 수정했습니다.
🛠️ 추후 리팩토링 및 고도화 계획
📸 스크린샷 (선택)
💬 리뷰 요구사항
Summary by CodeRabbit
릴리스 노트
Bug Fixes
Chores