mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-05-12 14:24:43 +00:00
47d081c705
## Problem Every time new data is ingested (`IngestNewFromDB`, `IngestNewObservations`, `EvictStale`), **all 6 analytics caches** are wiped by creating new empty maps — regardless of what kind of data actually changed. With the poller running every 1 second, this means the 15s cache TTL is effectively bypassed because caches are cleared far more frequently than they expire. ## Fix Introduces a `cacheInvalidation` flags struct and `invalidateCachesFor()` method that selectively clears only the caches affected by the ingested data: | Flag | Caches Cleared | |------|----------------| | `hasNewObservations` | RF (SNR/RSSI data changed) | | `hasNewPaths` | Topology, Distance, Subpaths | | `hasNewTransmissions` | Hash sizes | | `hasChannelData` | Channels (GRP_TXT payload_type 5) + channels list cache | | `eviction` | All (data removed, everything potentially stale) | ### Impact For a typical ingest cycle with ADVERT/ACK/TXT_MSG packets (no GRP_TXT): - **Before:** All 6 caches cleared every cycle - **After:** Channel cache preserved (most common case), hash cache preserved on observation-only ingestion For observation-only ingestion (`IngestNewObservations`): - **Before:** All 6 caches cleared - **After:** Only RF cache cleared (+ topo/dist/subpath if paths actually changed) ## Tests 7 new unit tests in `cache_invalidation_test.go` covering: - Eviction clears all caches - Observation-only ingest preserves non-RF caches - Transmission-only ingest clears only hash cache - Channel data clears only channel cache - Path changes clear topo/dist/subpath - Combined flags work correctly - No flags = no invalidation All existing tests pass. ### Post-rebase fix Restored `channelsCacheRes` invalidation that was accidentally dropped during the refactor. The old code cleared this separate channels list cache on every ingest, but `invalidateCachesFor()` didn't include it. Now cleared on `hasChannelData` and `eviction`. Fixes #375 --------- Co-authored-by: you <you@example.com>
34 lines
599 B
Plaintext
34 lines
599 B
Plaintext
node_modules/
|
|
data/
|
|
*.bak
|
|
*.db
|
|
*.db-journal
|
|
config.json
|
|
.env
|
|
data-lincomatic/
|
|
config-lincomatic.json
|
|
theme.json
|
|
firmware/
|
|
coverage/
|
|
public-instrumented/
|
|
.nyc_output/
|
|
.setup-state
|
|
# Squad: ignore runtime state (logs, inbox, sessions)
|
|
.squad/orchestration-log/
|
|
.squad/log/
|
|
.squad/decisions/inbox/
|
|
.squad/sessions/
|
|
# Squad: SubSquad activation file (local to this machine)
|
|
.squad-workstream
|
|
# Temp scripts / build artifacts
|
|
recover-delta.sh
|
|
merge.sh
|
|
replacements.txt
|
|
reps.txt
|
|
cmd/server/server.exe
|
|
cmd/ingestor/ingestor.exe
|
|
# CI trigger
|
|
!test-fixtures/e2e-fixture.db
|
|
corescope-server
|
|
cmd/server/server
|