Bugfix/cache settings getclientcheck - #3275
Closed
danoswaltCL wants to merge 2 commits into
Closed
Conversation
…p a little time from every client call
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces caching for the global “client check” settings to avoid a database read on every clientlib request, reducing per-request latency and freeing a DB connection from the hot path.
Changes:
- Added a dedicated cache key prefix for settings and introduced per-category TTL support for settings (
CACHING_TTL_SETTINGS). - Updated
SettingService.getClientCheck()to useCacheService.wrap()and invalidated that cache key insetClientCheck(). - Expanded/adjusted unit tests to provide a
CacheServiceand to assertgetClientCheckcaching + invalidation behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/types/src/Experiment/enums.ts | Adds a cache prefix for settings keys. |
| packages/backend/src/env.ts | Adds CACHING_TTL_SETTINGS to backend env configuration. |
| packages/backend/src/api/services/CacheService.ts | Adds a settings cache bucket and TTL wiring for the new prefix. |
| packages/backend/src/api/services/SettingService.ts | Wraps getClientCheck in cache and invalidates on setClientCheck. |
| packages/backend/test/unit/services/SettingService.test.ts | Adds cache-aware tests validating caching + invalidation behavior. |
| packages/backend/test/unit/services/MetricService.test.ts | Provides a pass-through CacheService stub to keep existing tests behavior stable. |
| packages/backend/.env.example | Documents the new CACHING_TTL_SETTINGS env var. |
| packages/backend/src/api/services/ImportExportService.ts | Changes TypeORM relation loading strategy for experiment export (scope mismatch with PR description). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| logger.info({ message: `Inside export Experiment JSON ${experimentIds}` }); | ||
| const experimentDetails = await this.experimentRepository.find({ | ||
| where: experimentIds ? { id: In(experimentIds) } : undefined, | ||
| relationLoadStrategy: 'query', |
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.
the ClientCheck middleware is called on every client call. it eats up a little time in every call. this data hardly ever changes, and really ought to be in the env vars honestly, but anyway, not fetching this gives us a handful of milliseconds and frees up a db connection on every single client call.