Skip to content

Add dedicated cache TTL config for stats/summary - #60

Merged
christabel888 merged 2 commits into
Stellar-Insightss:mainfrom
ndii-dev:issue-4-stats-summary-cache-ttl
Aug 28, 2026
Merged

Add dedicated cache TTL config for stats/summary#60
christabel888 merged 2 commits into
Stellar-Insightss:mainfrom
ndii-dev:issue-4-stats-summary-cache-ttl

Conversation

@ndii-dev

Copy link
Copy Markdown

Closes #4

Adds a stats_summary_ttl field to CacheConfig (env CACHE_STATS_SUMMARY_TTL), used by #1's /api/v1/stats/summary handler via cached_query and the new keys::stats_summary() cache key. Defaults to dashboard_stats_ttl (CACHE_DASHBOARD_STATS_TTL) rather than a hardcoded value, so an existing deployment's dashboard TTL customization carries over automatically unless a different freshness window is explicitly requested for the homepage tiles.

Also documents CACHE_STATS_SUMMARY_TTL in .env.example and adds two tests: one confirming the fallback-to-dashboard-ttl behavior, one confirming the override works independently.

Note: #1's endpoint (separate PR) already wires up caching using this same get_ttl("stats_summary")/keys::stats_summary() pattern; this PR formalizes the dedicated TTL config so it isn't just reusing the raw dashboard key by coincidence.

yosemite01 and others added 2 commits August 21, 2026 19:35
…ar-Insightss#4)

CacheConfig gains stats_summary_ttl (env CACHE_STATS_SUMMARY_TTL),
defaulting to dashboard_stats_ttl so existing CACHE_DASHBOARD_STATS_TTL
customizations carry over unless explicitly overridden. Adds
keys::stats_summary() cache key builder and tests covering both the
fallback and override paths.
Conflict in src/cache.rs was a trivial comment wording difference,
resolved by keeping the grammatically-correct plural.

Also fixed a real bug this merge chain exposed: Stellar-Insightss#54 and Stellar-Insightss#58 (both
already merged to main) independently numbered their migrations 031
(031_create_network_metrics_timeseries.sql and
031_create_daily_stat_snapshots.sql). sqlx::migrate! requires unique
version numbers per migration, so main was left in a broken state.
Renumbered the latter to 034_create_daily_stat_snapshots.sql (the
next free slot after 032/033) — no code or other migration references
the old filename.

Verified with cargo check (clean).
@christabel888
christabel888 merged commit 3ad5461 into Stellar-Insightss:main Aug 28, 2026
1 check failed
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.

Add caching for /api/v1/stats/summary via src/cache (short TTL)

4 participants