Skip to content

Commit 989cba0

Browse files
committed
feat: 상품 목록 & 상세 조회 캐싱
1 parent 8ded507 commit 989cba0

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

apps/commerce-api/src/main/java/com/loopers/application/product/ProductFacade.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.loopers.support.error.CoreException;
99
import com.loopers.support.error.ErrorType;
1010
import lombok.RequiredArgsConstructor;
11+
import org.springframework.cache.annotation.Cacheable;
1112
import org.springframework.stereotype.Component;
1213
import org.springframework.transaction.annotation.Transactional;
1314

@@ -36,6 +37,7 @@ public ProductInfo registerProduct(ProductV1Dto.ProductRequest request) {
3637
}
3738

3839
@Transactional(readOnly = true)
40+
@Cacheable(value = "products", key = "'all'")
3941
public List<ProductInfo> findAllProducts() {
4042
List<Product> products = productRepository.findAll();
4143

@@ -45,6 +47,7 @@ public List<ProductInfo> findAllProducts() {
4547
}
4648

4749
@Transactional(readOnly = true)
50+
@Cacheable(value = "product", key = "#id")
4851
public ProductInfo findProductById(Long id) {
4952
Product product = productRepository.findById(id).orElseThrow(
5053
() -> new CoreException(ErrorType.NOT_FOUND, "찾고자 하는 상품이 존재하지 않습니다.")

0 commit comments

Comments
 (0)