优化 缓存
This commit is contained in:
parent
2998e828ae
commit
91b99ef557
|
|
@ -71,7 +71,7 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|||
private final DraftDesignDataService draftDesignDataService;
|
||||
private final DraftDesignDataMapper draftDesignDataMapper;
|
||||
|
||||
private static final int TMP_CACHE_TIME = 1000 * 60 * 10;
|
||||
private static final int TMP_CACHE_TIME = 1000 * 60;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createProductInfo(ProductInfoSaveReqVO createReqVO) {
|
||||
|
|
@ -489,6 +489,12 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|||
wrapperFileIds(vo);
|
||||
resList.add(vo);
|
||||
});
|
||||
// 每次清空缓存
|
||||
brandNameCache.clear();
|
||||
ProductTypeNameCache.clear();
|
||||
CustomerGroupNameCache.clear();
|
||||
brandIdCache.clear();
|
||||
ProductTypeIdCache.clear();
|
||||
return resList;
|
||||
}
|
||||
private ProductInfoRespVO wrapperFileIds(ProductInfoRespVO vo){
|
||||
|
|
@ -594,6 +600,7 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static LFUCache<String,Long> ProductTypeIdCache = CacheUtil.newLFUCache(10000, TMP_CACHE_TIME);
|
||||
|
||||
private Long toProductTypeId(String name){
|
||||
|
|
@ -614,6 +621,7 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|||
return s;
|
||||
}
|
||||
private void initProductTypeNameCache(Set<Long> ids){
|
||||
ProductTypeNameCache.clear();
|
||||
if(FuncUtil.isNotEmpty(ids)){
|
||||
List<ProductTypeDO> dos = productTypeMapper.selectBatchIds(ids);
|
||||
for (ProductTypeDO db : dos) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue