diff --git a/src/main/java/com/ongil/backend/domain/brand/service/BrandService.java b/src/main/java/com/ongil/backend/domain/brand/service/BrandService.java index 6c01005..2f1d46b 100644 --- a/src/main/java/com/ongil/backend/domain/brand/service/BrandService.java +++ b/src/main/java/com/ongil/backend/domain/brand/service/BrandService.java @@ -23,7 +23,9 @@ import com.ongil.backend.global.config.redis.RedisCacheService; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j @Service @RequiredArgsConstructor @Transactional(readOnly = true) @@ -43,7 +45,7 @@ public List getAllBrands() { BrandResponse.class ); - if (cached != null) { + if (cached != null && !cached.isEmpty()) { return cached; } @@ -51,6 +53,11 @@ public List getAllBrands() { List brands = brandRepository.findAllOrderByName(); List response = brandConverter.toResponseList(brands); + if (response.isEmpty()) { + log.warn("조회된 브랜드가 없습니다."); + return response; + } + // Redis 캐싱 (무한 TTL) redisCacheService.save( CacheKeyConstants.BRANDS_ALL, diff --git a/src/main/java/com/ongil/backend/domain/category/service/CategoryService.java b/src/main/java/com/ongil/backend/domain/category/service/CategoryService.java index 7e72d8b..51f4f89 100644 --- a/src/main/java/com/ongil/backend/domain/category/service/CategoryService.java +++ b/src/main/java/com/ongil/backend/domain/category/service/CategoryService.java @@ -23,7 +23,9 @@ import com.ongil.backend.global.config.redis.RedisCacheService; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j @Service @RequiredArgsConstructor @Transactional(readOnly = true) @@ -42,7 +44,7 @@ public List getAllCategories() { CategoryResponse.class ); - if (cached != null) { + if (cached != null && !cached.isEmpty()) { return cached; } @@ -67,6 +69,11 @@ public List getAllCategories() { .filter(r -> r != null) .collect(Collectors.toList()); + if (response.isEmpty()) { + log.warn("조회된 카테고리가 없습니다."); + return response; + } + // Redis 캐싱 (무한 TTL) redisCacheService.save( CacheKeyConstants.CATEGORIES_ALL,