缓存 TTL 对齐:图表内存/会话缓存统一降为 5 分钟(metar),与大表刷新同步

- HOURLY_CACHE_TTL_MS: model(30min) → metar(5min)
- SESSION_CACHE_TTL_MS: 10min → metar(5min)
- 消除大表已刷新但折线图仍显示旧温度的时差问题
This commit is contained in:
2569718930@qq.com
2026-05-26 08:13:37 +08:00
parent 8a534160f0
commit 5d10d60dcb
2 changed files with 4 additions and 4 deletions
@@ -192,7 +192,7 @@ type RunwayHistorySeries = {
};
const MAX_OBS_POINTS = 1440;
const HOURLY_CACHE_TTL_MS = DASHBOARD_REFRESH_POLICY_MS.model;
const HOURLY_CACHE_TTL_MS = DASHBOARD_REFRESH_POLICY_MS.metar;
const FULL_DAY_SLOT_MINUTES = 30;
const FULL_DAY_SLOTS = 48;
const SLOT_INTERVAL_MS = FULL_DAY_SLOT_MINUTES * 60 * 1000;
@@ -201,7 +201,7 @@ const _hourlyRequestCache = new Map<string, Promise<HourlyForecast>>();
const RUNWAY_LINE_COLORS = ["#00897b", "#d97706", "#7c3aed", "#0891b2", "#ea580c", "#64748b"];
const SESSION_CACHE_PREFIX = "polyweather_city_detail_v1:";
const SESSION_CACHE_TTL_MS = 10 * 60 * 1000; // 10 minutes cache for session storage
const SESSION_CACHE_TTL_MS = DASHBOARD_REFRESH_POLICY_MS.metar;
function readSessionCache(city: string): { ts: number; data: HourlyForecast } | null {
if (typeof window === "undefined") return null;
@@ -33,10 +33,10 @@ export function runTests() {
"scan list local cache should use the shared 5-minute row cadence",
);
assert(
chartSource.includes("DASHBOARD_REFRESH_POLICY_MS.model") &&
chartSource.includes("DASHBOARD_REFRESH_POLICY_MS.metar") &&
!chartSource.includes("setInterval(") &&
!chartSource.includes("window.setInterval"),
"selected city detail chart should be on-demand and use model-layer cache instead of 60-second polling",
"selected city detail chart cache should align with 5-minute scan/metar cadence",
);
assert(
chartSource.includes("_hourlyRequestCache") &&