debug: add RF cache logging

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Kpa-clawbot
2026-03-27 09:43:40 -07:00
co-authored by Copilot
parent 6158734536
commit b42d7e3f14
+4
View File
@@ -1240,17 +1240,21 @@ func (s *PacketStore) GetAnalyticsRF(region string) map[string]interface{} {
s.cacheMu.Lock()
if cached, ok := s.rfCache[region]; ok && time.Now().Before(cached.expiresAt) {
s.cacheMu.Unlock()
log.Printf("[rf-cache] HIT region=%q ttl=%.1fs", region, time.Until(cached.expiresAt).Seconds())
return cached.data
}
s.cacheMu.Unlock()
// Compute fresh result
t0 := time.Now()
result := s.computeAnalyticsRF(region)
elapsed := time.Since(t0)
// Cache result
s.cacheMu.Lock()
s.rfCache[region] = &cachedResult{data: result, expiresAt: time.Now().Add(s.rfCacheTTL)}
s.cacheMu.Unlock()
log.Printf("[rf-cache] MISS region=%q computed in %v, cached for %v", region, elapsed, s.rfCacheTTL)
return result
}