mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-05-25 18:14:03 +00:00
perf: smart cache invalidation — only channels/observers on packet burst, node/health/analytics expire by TTL, node invalidated on ADVERT only
This commit is contained in:
@@ -75,12 +75,10 @@ class TTLCache {
|
||||
if (this._debounceTimer) return;
|
||||
this._debounceTimer = setTimeout(() => {
|
||||
this._debounceTimer = null;
|
||||
this.invalidate('analytics:');
|
||||
this.invalidate('channels');
|
||||
this.invalidate('node:');
|
||||
this.invalidate('health:');
|
||||
this.invalidate('observers');
|
||||
this.invalidate('bulk-health');
|
||||
// Only invalidate truly time-sensitive caches
|
||||
this.invalidate('channels'); // chat messages need freshness
|
||||
this.invalidate('observers'); // observer packet counts
|
||||
// node:, health:, bulk-health, analytics: all have long TTLs — let them expire naturally
|
||||
}, TTL.invalidationDebounce);
|
||||
}
|
||||
clear() { this.store.clear(); }
|
||||
@@ -325,6 +323,10 @@ try {
|
||||
const p = decoded.payload;
|
||||
const role = p.flags ? (p.flags.repeater ? 'repeater' : p.flags.room ? 'room' : p.flags.sensor ? 'sensor' : 'companion') : 'companion';
|
||||
db.upsertNode({ public_key: p.pubKey, name: p.name || null, role, lat: p.lat, lon: p.lon, last_seen: now });
|
||||
// Invalidate this node's caches on advert
|
||||
cache.invalidate('node:' + p.pubKey);
|
||||
cache.invalidate('health:' + p.pubKey);
|
||||
cache.invalidate('bulk-health');
|
||||
}
|
||||
|
||||
if (observerId) {
|
||||
|
||||
Reference in New Issue
Block a user