Authored by caoyan

缓存

... ... @@ -423,6 +423,17 @@ public class ProductController {
LOG.info("clearProductCaches success skup = {}", skup);
return new ApiResponse(200, "缓存清除成功!", Boolean.TRUE);
}
@RequestMapping("/product/clearProductDetailCache")
@IgnoreSignature
@IgnoreSession
public ApiResponse clearProductDetailCache(@RequestBody ProductRequestBo bo) {
Integer productId = bo.getId();
LOG.info("in clearProductDetailCache productId={}", productId);
clearProductDetailCache(productId);
LOG.info("clearProductDetailCache success productId = {}", productId);
return new ApiResponse(200, "缓存清除成功!", Boolean.TRUE);
}
@Autowired
private ControllerCacheAop cacheAop;
... ... @@ -484,6 +495,21 @@ public class ProductController {
}
});
}
private void clearProductDetailCache(Integer productId) {
executors.execute(() -> {
try {
LOG.info("in clearProductDetailCache productId = {}", productId);
// 商品详情:数量
LOG.info("clearCache queryProductDetailById productId = {}, ", productId);
cacheAop.clearCache(
ProductController.class.getMethod("queryProductDetailById", new Class[]{Integer.class}),
new Object[]{productId});
} catch (Exception e) {
LOG.error("删除商品详情缓存失败!", e);
}
});
}
private void clearBatchProductCache(List<Integer> skupList) {
... ...