Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -43,14 +45,19 @@ public List<BrandResponse> getAllBrands() {
BrandResponse.class
);

if (cached != null) {
if (cached != null && !cached.isEmpty()) {
return cached;
}

// Cache Miss → DB 조회
List<Brand> brands = brandRepository.findAllOrderByName();
List<BrandResponse> response = brandConverter.toResponseList(brands);

if (response.isEmpty()) {
log.warn("조회된 브랜드가 없습니다.");
return response;
}

// Redis 캐싱 (무한 TTL)
redisCacheService.save(
CacheKeyConstants.BRANDS_ALL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -42,7 +44,7 @@ public List<CategoryResponse> getAllCategories() {
CategoryResponse.class
);

if (cached != null) {
if (cached != null && !cached.isEmpty()) {
return cached;
}

Expand All @@ -67,6 +69,11 @@ public List<CategoryResponse> getAllCategories() {
.filter(r -> r != null)
.collect(Collectors.toList());

if (response.isEmpty()) {
log.warn("조회된 카테고리가 없습니다.");
return response;
}

// Redis 캐싱 (무한 TTL)
redisCacheService.save(
CacheKeyConstants.CATEGORIES_ALL,
Expand Down