Skip to content

perf(api): cache total wallets metric#938

Open
raymondjacobson wants to merge 1 commit into
mainfrom
codex/cache-total-wallets-metric
Open

perf(api): cache total wallets metric#938
raymondjacobson wants to merge 1 commit into
mainfrom
codex/cache-total-wallets-metric

Conversation

@raymondjacobson

Copy link
Copy Markdown
Member

Summary

  • add a tiny per-server TTL cache for /v1/metrics/total_wallets
  • keep the cache bounded to 16 entries with a 5 minute TTL
  • add handler coverage for the cached response path

Evidence

  • prod read-only pg_stat_statements showed the total-wallets aggregate query at roughly 750k calls, 943k total seconds, and ~1.26s mean time since stats reset
  • the endpoint returns a coarse aggregate count, so a short TTL removes repeated count scans while accepting only brief staleness

Test Plan

  • go test ./api -run 'TestMetricsTotalWallets' -count=1\n- git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant