Repository navigation
Fix (config): Read CACHE_LOCAL_TTL for the local cache TTL - #2760
Open
VitorCoelho wants to merge 1 commit into
Open
VitorCoelho wants to merge 1 commit into
VitorCoelho wants to merge 1 commit into
Conversation
CACHE.LOCAL.TTL was parsed from CACHE_REDIS_TTL, so CACHE_LOCAL_TTL (documented in env.example) was ignored and the local cache used the Redis TTL instead.
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes local cache TTL configuration to honor File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/config/env.config.ts" line_range="885" />
<code_context>
LOCAL: {
ENABLED: process.env?.CACHE_LOCAL_ENABLED === 'true',
- TTL: Number.parseInt(process.env?.CACHE_REDIS_TTL) || 86400,
+ TTL: Number.parseInt(process.env?.CACHE_LOCAL_TTL) || 86400,
},
},
</code_context>
<issue_to_address>
**Zero local TTL resets to one day**
When `CACHE_LOCAL_TTL` is set to `0`, `Number.parseInt(...) || 86400` treats zero as missing, so `LocalCache` receives 86400 instead of the zero TTL, and entries expire after one day rather than remaining unexpired.
Use a fallback that applies only when the value is absent or invalid, while preserving zero as a valid TTL.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if CACHE_LOCAL_TTL is missing or wrong, local cache entries may live for the fallback or misconfigured duration; reverting does not necessarily change expirations already assigned to entries. The effect is bounded to the in-memory cache and can be cleared or allowed to expire.
Blocking findings: src/config/env.config.ts:885
This branch has not been deployed
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.
📋 Description
CACHE.LOCAL.TTLinsrc/config/env.config.tsis parsed fromCACHE_REDIS_TTLinstead ofCACHE_LOCAL_TTL:That way, the
CACHE_LOCAL_TTLvariable documented inenv.exampleis never read. With the example values (CACHE_REDIS_TTL=604800,CACHE_LOCAL_TTL=86400), the local cache keeps entries for 7 days instead of 1. This PR makes it readCACHE_LOCAL_TTL. The default (86400) is unchanged.🔗 Related Issue
No existing issue; found while reading the config.
🧪 Type of Change
🧪 Testing
CACHE_LOCAL_TTLis now the only source ofCACHE.LOCAL.TTL, whichLocalCacheuses as its default TTL (src/cache/localcache.ts)CACHE_LOCAL_TTLstill get 86400✅ Checklist
Summary by Sourcery
Bug Fixes:
CACHE_LOCAL_TTLwhen configuring the local cache TTL, while preserving the existing 86400-second default.