Summary
The leaderboard query aggregates token balances across all learners and is one of the most expensive database queries. Caching the result in Redis with a short TTL (60 s) would dramatically reduce DB load.
Proposed Approach
- On request, check Redis for a
leaderboard:top100 key
- Cache hit → return cached JSON immediately
- Cache miss → run DB query, store result with 60 s TTL, return
Acceptance Criteria
Files
server/src/controllers/
server/src/lib/
Summary
The leaderboard query aggregates token balances across all learners and is one of the most expensive database queries. Caching the result in Redis with a short TTL (60 s) would dramatically reduce DB load.
Proposed Approach
leaderboard:top100keyAcceptance Criteria
server/src/lib/REDIS_URLadded toserver/.env.exampleFiles
server/src/controllers/server/src/lib/