Skip to content

feat: add Redis-backed caching for external API calls#157

Merged
YaronZaki merged 1 commit into
Quantarq:mainfrom
Divineifed1:main
Jun 22, 2026
Merged

feat: add Redis-backed caching for external API calls#157
YaronZaki merged 1 commit into
Quantarq:mainfrom
Divineifed1:main

Conversation

@Divineifed1

@Divineifed1 Divineifed1 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

close #58
summary:

Reduces redundant external API calls by caching token prices and Stellar balance queries in Redis.

Changes

quantara/web_app/contract_tools/cache.py (new): shared async Redis cache utility with lazy connection pool and graceful fallback on cache errors.
quantara/web_app/contract_tools/mixins/dashboard.py: DashboardMixin.get_current_prices() now cached at quantara:prices with 30s TTL.
quantara/web_app/contract_tools/blockchain_call.py: StellarClient.get_token_balances() now cached at quantara:balances:{address} with 60s TTL.
Impact

Removes N+1 per-user Horizon calls on each dashboard request.
Eliminates CoinGecko fetch on every dashboard refresh.
Cache is disabled-on-failure: Redis outage falls through to existing API fetch behavior with a warning log.
Notes for reviewers

Uses redis.asyncio from the already-pinned redis==8.0.0 dependency; no new packages.
REDIS_URL env var pattern matches existing usage in the rate limiter and health check.
Mock tests targeting APIRequest/get_token_balances should remain green because configuration runs through the patched names

Copy link
Copy Markdown
Contributor

✅ Looks good, @Divineifed1. Clean separation between the cache helper and existing call sites, sensible TTLs (60s balances, 30s prices), and Redis is a nice pick. Merging.

@YaronZaki YaronZaki merged commit bc3513d into Quantarq:main Jun 22, 2026
3 checks passed
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.

perf: Implement caching layer for token prices and blockchain queries

2 participants