Commit 9bcaf5b2 authored by duanruiming's avatar duanruiming

[add] 缓存问题优化

parent 8575319b
......@@ -48,6 +48,7 @@ import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
/**
......@@ -87,8 +88,8 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
@Resource
private GreenChartSchemeHistMapper greenChartSchemeHistMapper;
private static List<OptMonitoringVO> greenListCache = new ArrayList<>(10);
private static List<OptMonitoringVO> crossListCache = new ArrayList<>(80);
private static List<OptMonitoringVO> greenListCache = new CopyOnWriteArrayList<>();
private static List<OptMonitoringVO> crossListCache = new CopyOnWriteArrayList<>();
@Override
......@@ -243,8 +244,10 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
}
}
});
greenListCache.clear();
greenListCache.addAll(optMonitoringVOS);
if (!CollectionUtils.isEmpty(greenListCache)) {
greenListCache.clear();
greenListCache.addAll(optMonitoringVOS);
}
return optMonitoringVOS;
}
......@@ -287,8 +290,10 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
}
}
});
crossListCache.clear();
crossListCache.addAll(optMonitoringVOS);
if (!CollectionUtils.isEmpty(crossListCache)) {
crossListCache.clear();
crossListCache.addAll(optMonitoringVOS);
}
return optMonitoringVOS;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment