File tree Expand file tree Collapse file tree
apps/commerce-api/src/main/java/com/loopers/application/product Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import com .loopers .support .error .CoreException ;
99import com .loopers .support .error .ErrorType ;
1010import lombok .RequiredArgsConstructor ;
11+ import org .springframework .cache .annotation .Cacheable ;
1112import org .springframework .stereotype .Component ;
1213import 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 , "찾고자 하는 상품이 존재하지 않습니다." )
You can’t perform that action at this time.
0 commit comments