1、查询任务树列表,先移除缓存,后期再优化

This commit is contained in:
2026-01-14 10:24:51 +08:00
parent a9655879c4
commit 62d8a43535

View File

@@ -2577,13 +2577,13 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
return new ArrayList<>();
}
// 构建缓存key唯一标识本次查询
String cacheKey = "taskTree_" + req.getIdMap().stream().map(t -> t.getKey() + "_" + t.getValue()).collect(Collectors.joining(","));
Cache cache = cacheManager.getCache("taskTreeListCache");
if (cache != null && cache.get(cacheKey) != null) {
// 缓存命中直接返回不调用getTaskTree()
log.info("--------------------------命中缓存--------------------------");
return (List<NodeAllBase>) cache.get(cacheKey).get();
}
// String cacheKey = "taskTree_" + req.getIdMap().stream().map(t -> t.getKey() + "_" + t.getValue()).collect(Collectors.joining(","));
// Cache cache = cacheManager.getCache("taskTreeListCache");
// if (cache != null && cache.get(cacheKey) != null) {
// // 缓存命中直接返回不调用getTaskTree()
// log.info("--------------------------命中缓存--------------------------");
// return (List<NodeAllBase>) cache.get(cacheKey).get();
// }
// 缓存未命中,执行原逻辑
SdmResponse taskTree = getTaskTree(req);
if (taskTree == null || taskTree.getData() == null) {
@@ -2598,9 +2598,9 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
}
List<NodeAllBase> result = dataList.stream().map(NodeAllBase.class::cast).collect(Collectors.toList());
// 存入缓存设置过期时间根据业务调整比如5分钟避免数据不一致
if (cache != null) {
cache.put(cacheKey, result);
}
// if (cache != null) {
// cache.put(cacheKey, result);
// }
return result;
}