feat(caching): add aggressive caching for expensive computations #603#736
Merged
RUKAYAT-CODER merged 1 commit intoMay 30, 2026
Conversation
|
@David-282 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Closes #603
What does this PR do?
Adds a dedicated
ComputationCacheServicefor expensive O(n) operations inLeaderboardServicethat were hitting the database on every request with nocaching. Implements cache-aside pattern with stampede protection, per-computation
TTL configuration, and Prometheus metrics tracking via the existing
MetricsCollectionService.Type of change
Pre-merge checklist (required)
Branch & metadata
feature/issue-<N>-<slug>/fix/issue-<N>-<slug>conventionCode quality & tests
npm run lint:cinpm run format:checknpm run typechecknpm run test:ci.spec.tsunit testsError handling & NestJS best practices
Loggerwith structured messagesAPI documentation / Swagger
Breaking changes
Test evidence (required)
Commands run locally
Manual / API verification
No new endpoints introduced. Changes are internal service layer only.
Unit tests cover: cache hit, cache miss, stampede deduplication,
invalidation, hit rate calculation, and Prometheus metrics publishing.
Files changed
src/caching/computation-cache.service.ts— new servicesrc/caching/computation-cache.service.spec.ts— unit testssrc/caching/caching.constants.ts— addedCOMPUTATION_TTLsrc/caching/cache-key.builder.ts— addedbuildComputationKey()src/caching/caching.module.ts— registered and exportedComputationCacheService