|
|
@@ -34,25 +34,24 @@ public abstract class AbstractTagsCache implements InitializingBean, TagCache { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void afterPropertiesSet() { |
|
|
|
// tagsCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) |
|
|
|
// .refreshAfterWrite(5, TimeUnit.MINUTES) |
|
|
|
// .build(key -> { |
|
|
|
// // 查询全部 |
|
|
|
// List<TagDTO> tagDTOList = iMetaTagService.queryAll(); |
|
|
|
// // TODO 临时关闭校验 |
|
|
|
//// Assert.isTrue(CollectionUtils.isNotEmpty(tagDTOList), "MetaTags queryAll is Empty"); |
|
|
|
// tagDtoMap = buildCateMap(tagDTOList); |
|
|
|
// List<TagDTO> tagInLevel = tagDTOList.stream().filter(tagDto -> { |
|
|
|
// // 只过滤出小于等于level的tag |
|
|
|
// if (Objects.isNull(tagDto.getTagLevel())) { |
|
|
|
// return false; |
|
|
|
// } |
|
|
|
// return Integer.parseInt(key) >= tagDto.getTagLevel(); |
|
|
|
// }).collect(Collectors.toList()); |
|
|
|
// List<TagTreeDTO> treeDtos = MetaTagAssembler.toTagTreeDTOList(tagInLevel); |
|
|
|
// return toTreeStructure(treeDtos); |
|
|
|
// }); |
|
|
|
// warmUp(); |
|
|
|
tagsCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) |
|
|
|
.refreshAfterWrite(5, TimeUnit.MINUTES) |
|
|
|
.build(key -> { |
|
|
|
// 查询全部 |
|
|
|
List<TagDTO> tagDTOList = iMetaTagService.queryAll(); |
|
|
|
Assert.isTrue(CollectionUtils.isNotEmpty(tagDTOList), "MetaTags queryAll is Empty"); |
|
|
|
tagDtoMap = buildCateMap(tagDTOList); |
|
|
|
List<TagDTO> tagInLevel = tagDTOList.stream().filter(tagDto -> { |
|
|
|
// 只过滤出小于等于level的tag |
|
|
|
if (Objects.isNull(tagDto.getTagLevel())) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return Integer.parseInt(key) >= tagDto.getTagLevel(); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
List<TagTreeDTO> treeDtos = MetaTagAssembler.toTagTreeDTOList(tagInLevel); |
|
|
|
return toTreeStructure(treeDtos); |
|
|
|
}); |
|
|
|
warmUp(); |
|
|
|
} |
|
|
|
|
|
|
|
private Map<String, TagDTO> buildCateMap(List<TagDTO> tagDTOList) { |
|
|
|