Merge pull request 'release: 2026-03-24.4 (캐시 TTL 수정)' (#183) from develop into main
All checks were successful
Deploy KCG / deploy (push) Successful in 1m56s
All checks were successful
Deploy KCG / deploy (push) Successful in 1m56s
This commit is contained in:
커밋
1029e07432
@ -24,6 +24,9 @@ public class GroupPolygonService {
|
|||||||
private final CacheManager cacheManager;
|
private final CacheManager cacheManager;
|
||||||
private final ObjectMapper objectMapper;
|
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 = """
|
private static final String LATEST_GROUPS_SQL = """
|
||||||
SELECT group_type, group_key, group_label, snapshot_time,
|
SELECT group_type, group_key, group_label, snapshot_time,
|
||||||
ST_AsGeoJSON(polygon) AS polygon_geojson,
|
ST_AsGeoJSON(polygon) AS polygon_geojson,
|
||||||
@ -61,7 +64,9 @@ public class GroupPolygonService {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<GroupPolygonDto> getLatestGroups() {
|
public List<GroupPolygonDto> getLatestGroups() {
|
||||||
Cache cache = cacheManager.getCache(CacheConfig.GROUP_POLYGONS);
|
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");
|
Cache.ValueWrapper wrapper = cache.get("data");
|
||||||
if (wrapper != null) {
|
if (wrapper != null) {
|
||||||
return (List<GroupPolygonDto>) wrapper.get();
|
return (List<GroupPolygonDto>) wrapper.get();
|
||||||
@ -72,6 +77,7 @@ public class GroupPolygonService {
|
|||||||
|
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
cache.put("data", results);
|
cache.put("data", results);
|
||||||
|
lastCacheTime = now;
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|||||||
불러오는 중...
Reference in New Issue
Block a user