dashboard: live cache-age indicator
The web server's dashboardStats now reports how stale its shared cache
snapshot is — data.cache = { enabled, ttlMs, ageMs }, using the age of the
oldest dataset feeding the view (OLT-STATE, plus ONU-STATE under detailed
scan). cache.js gains ageOf(key).
The dashboard renders a live-ticking badge from it (renderCacheBadge):
- within TTL -> "◷ cached Ns ago" (info)
- past TTL -> same, warn-coloured (next load will refetch)
- no cache -> "● live" (Electron app, or PFW_CACHE_TTL_SECONDS=0)
The Dashboard Refresh button now sends fresh:true to bypass the cache and
reset the age; the detailed-stats toggle and auto-loads use the cache.
Shared renderer change, so the Electron app shows "live" (it sends no cache
field). Verified offscreen over HTTP: cached / stale / live states render
with the right text + colour.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
6ee1d37a79
commit
c2206ad5a7
6 changed files with 84 additions and 5 deletions
|
|
@ -51,6 +51,12 @@ class TtlCache {
|
|||
return p;
|
||||
}
|
||||
|
||||
/** Age (ms) of the cached entry for `key`, or null if not cached. */
|
||||
ageOf(key) {
|
||||
const e = this.entries.get(key);
|
||||
return e ? Date.now() - e.at : null;
|
||||
}
|
||||
|
||||
/** Drop every entry whose key starts with `prefix` (e.g. one MCMS host's
|
||||
* dataset). Returns how many were removed. */
|
||||
invalidate(prefix) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue