mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-08-28 12:44:12 +00:00
debug: add RF cache logging
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user