-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
🎯 Issue Type
- Enhancement
📋 Description
Problem/Need
Older endpoints in apps/backend/src/routes/repositoryRoutes.ts still implement their own caching logic: they manually set and get Redis keys and clone a repository via withTempRepository() on each call. This bypasses the Cache Service and HybridLRUCache described in the Caching System documentation. As a result, commit data is cloned multiple times, aggregated data is recomputed unnecessarily, and manual Redis operations ignore tier promotion and cache invalidation semantics.
Expected Behavior
- All routes should delegate caching to
getCachedCommits(),getCachedAggregatedData()andgetCachedContributors()fromrepositoryCache.ts. - The unified cache should handle lookups across memory, disk, and Redis tiers, including automatic promotion, fallback, and invalidation.
- Redis remains part of the storage tier; the change removes only the manual cache handling from route handlers.
Current Behavior
- Endpoints like
POST /api/repositories,/heatmap,/contributors, and/full-datacheck Redis directly, clone the repository, and recompute commits or aggregations. - They do not leverage multi‑tier caching, resulting in duplicated Git operations and inconsistent cache invalidation.
🔄 Steps to Reproduce
- Spin up the backend and send a
POSTto/api/repositorieswith a repo URL. - Immediately call
POST /api/repositories/heatmapwith the same URL. - Observe that the second call clones the repo again instead of using cached commit data (logs show duplicate
gitService.getCommits()calls). - Compare to the new
GET /api/commitsandGET /api/commits/heatmapendpoints, which reuse cached data via the cache service.
🎨 Mockups/Screenshots
// Current manual caching (simplified)
const commitsKey = `commits:${repoUrl}`;
const cached = await redis.get(commitsKey);
if (!cached) {
const commits = await withTempRepository(repoUrl, (dir) => gitService.getCommits(dir));
await redis.set(commitsKey, JSON.stringify(commits));
}// Proposed unified caching usage
const cacheOptions: CommitCacheOptions = { skip: 0, limit: 1000 };
const commits = await getCachedCommits(repoUrl, cacheOptions);See Hybrid LRU Cache – Three‑Tier Storage Architecture for details on memory, disk, and Redis tiers and Cache Service for the unified API.
🧪 Acceptance Criteria
- Remove manual
redis.get/setlogic from older routes. - Replace direct
gitServicecalls withgetCachedCommits,getCachedAggregatedData, andgetCachedContributors. - Ensure that Redis remains configured as the third tier in cache configuration; only manual calls are removed.
- Add or update unit/integration tests to confirm that subsequent calls reuse cached data.
- Document the change in route comments and/or docs, referencing the caching system design.
🛠 Technical Details
Affected Files/Components
apps/backend/src/routes/repositoryRoutes.tsapps/backend/src/services/repositoryCache.ts(import/export usage)- Test suites for repository routes.
Dependencies
- None, though ensure configuration (
config.ts) still enables Redis if desired.
Breaking Changes
- Yes
- No
🏷 Categorization
Scope
- scope:backend
Priority
- prio:high
Effort
- effort:small
- effort:medium
📝 Additional Notes
- This refactor does not remove Redis from the caching infrastructure. It aligns the older routes with the multi‑tier cache design, as described in the Cache Invalidation and Hybrid LRU Cache pages.
- The repository’s cache configuration can still disable Redis if desired via
enableRedis, but that change would be separate.
Metadata
Metadata
Assignees
Labels
No labels