fix: hotfix 동기화 — history/detail candidate_count 안전 처리 #225
@ -24,6 +24,9 @@ public class GroupPolygonService {
|
||||
private final CacheManager cacheManager;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private static final long CACHE_TTL_MS = 5 * 60_000L; // 5분
|
||||
private volatile long lastCacheTime = 0;
|
||||
|
||||
private static final String LATEST_GROUPS_SQL = """
|
||||
SELECT group_type, group_key, group_label, snapshot_time,
|
||||
ST_AsGeoJSON(polygon) AS polygon_geojson,
|
||||
@ -61,7 +64,9 @@ public class GroupPolygonService {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<GroupPolygonDto> getLatestGroups() {
|
||||
Cache cache = cacheManager.getCache(CacheConfig.GROUP_POLYGONS);
|
||||
if (cache != null) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
if (cache != null && (now - lastCacheTime) < CACHE_TTL_MS) {
|
||||
Cache.ValueWrapper wrapper = cache.get("data");
|
||||
if (wrapper != null) {
|
||||
return (List<GroupPolygonDto>) wrapper.get();
|
||||
@ -72,6 +77,7 @@ public class GroupPolygonService {
|
||||
|
||||
if (cache != null) {
|
||||
cache.put("data", results);
|
||||
lastCacheTime = now;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user