Skip to content

Conversation

@jhheider
Copy link
Member

@jhheider jhheider commented Sep 9, 2025

Adds a caching layer to the leaderboard endpoint to reduce database load and improve response times. The cache stores project data and invalidates entries after a configurable time-to-live (TTL). Fetches missing projects from the database and updates the cache. Increments API version.

This reduces 100-package query time from 158s to 85ms (around a 2000x improvement) for local queries across the tunnel.

Adds a caching layer to the leaderboard endpoint to reduce database load and improve response times.
The cache stores project data and invalidates entries after a configurable time-to-live (TTL).
Fetches missing projects from the database and updates the cache.
Increments API version.
@jhheider jhheider requested review from antons0l and Copilot September 9, 2025 00:52

This comment was marked as outdated.

@jhheider jhheider requested a review from Copilot September 9, 2025 00:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a caching layer for the leaderboard endpoint to significantly improve performance by reducing database load. The cache stores project data with a 1-hour TTL and fetches only missing projects from the database.

Key changes:

  • Added project caching infrastructure with TTL-based expiration
  • Modified leaderboard logic to check cache first, then query database for missing projects
  • Incremented API version from 1.2.1 to 1.3.0

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
api/src/app_state.rs Adds ProjectCacheEntry struct and cache field to AppState
api/src/main.rs Initializes project cache in application startup
api/src/utils.rs Adds helper function to retrieve cached projects and identify missing ones
api/src/handlers.rs Updates leaderboard endpoint to use caching logic with fallback to database
api/Cargo.toml Adds dashmap dependency and increments version

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jhheider jhheider merged commit 1c7707f into chai-api-increase-leaderboard-limit Sep 10, 2025
4 checks passed
jhheider added a commit that referenced this pull request Sep 10, 2025
* Improves leaderboard performance with caching

Adds a caching layer to the leaderboard endpoint to reduce database load and improve response times.
The cache stores project data and invalidates entries after a configurable time-to-live (TTL).
Fetches missing projects from the database and updates the cache.
Increments API version.

* thank you, copilot.
@jhheider jhheider deleted the chai-cache-leaderboard branch September 10, 2025 14:32
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.

3 participants