-
Notifications
You must be signed in to change notification settings - Fork 44
[volume-5] 인덱스와 캐시를 활용한 상품 조회 읽기 성능 최적화 #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: madirony
Are you sure you want to change the base?
Changes from all commits
aa3d2ee
f60b4d3
a492e93
0eb4c33
7f2ae21
85ae499
c185621
cb2f3f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package com.loopers.application.product; | ||
|
|
||
| import com.loopers.domain.common.Money; | ||
| import com.loopers.domain.product.Product; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.extern.jackson.Jacksonized; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @Jacksonized | ||
| public class CachedBrandProductPage { | ||
| private final List<ProductSummary> content; | ||
| private final long totalElements; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @Jacksonized | ||
| public static class ProductSummary { | ||
| private final Long productId; | ||
| private final String productName; | ||
| private final Money basePrice; | ||
| private final boolean deleted; | ||
| private final long likeCount; | ||
|
|
||
| public static ProductSummary from(Product product) { | ||
| return ProductSummary.builder() | ||
| .productId(product.getId()) | ||
| .productName(product.getName()) | ||
| .basePrice(product.getBasePrice()) | ||
| .deleted(product.isDeleted()) | ||
| .likeCount(product.getLikeCount()) | ||
| .build(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package com.loopers.application.product; | ||
|
|
||
| import com.loopers.domain.common.Money; | ||
| import com.loopers.domain.product.Option; | ||
| import com.loopers.domain.product.Product; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.extern.jackson.Jacksonized; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @Jacksonized | ||
| public class CachedProductDetail { | ||
| private final Long productId; | ||
| private final String productName; | ||
| private final Money basePrice; | ||
| private final boolean deleted; | ||
| private final Long brandId; | ||
| private final long likeCount; | ||
| private final List<ProductInfo.OptionInfo> options; | ||
|
|
||
| public static CachedProductDetail from(Product product, List<Option> options, long likeCount) { | ||
| return CachedProductDetail.builder() | ||
| .productId(product.getId()) | ||
| .productName(product.getName()) | ||
| .basePrice(product.getBasePrice()) | ||
| .deleted(product.isDeleted()) | ||
| .brandId(product.getBrandId()) | ||
| .likeCount(likeCount) | ||
| .options(Optional.ofNullable(options).orElseGet(Collections::emptyList) | ||
| .stream().map(ProductInfo.OptionInfo::from).toList()) | ||
| .build(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.loopers.application.product; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface ProductCacheManager { | ||
|
|
||
| Optional<CachedBrandProductPage> getProductList(Long brandId, int page, int size); | ||
|
|
||
| void putProductList(Long brandId, int page, int size, CachedBrandProductPage value); | ||
|
|
||
| Optional<CachedProductDetail> getProductDetail(Long productId); | ||
|
|
||
| void putProductDetail(Long productId, CachedProductDetail value); | ||
|
|
||
| void evictProductCaches(Long productId, Long brandId); | ||
|
Comment on lines
+7
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 목록 캐시 무효화 계약이 키 차원을 모두 표현하지 못한다.
🤖 Prompt for AI Agents |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.