fix(backend): 그룹 폴리곤 캐시 TTL 5분 제한

- Caffeine 전역 TTL(2일) 대신 서비스 내 수동 5분 TTL 체크
- 5분마다 DB에서 최신 스냅샷 재조회 보장
This commit is contained in:
htlee 2026-03-24 14:20:53 +09:00
부모 7d9cfe4456
커밋 205de674bb

파일 보기

@ -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;
}