Skip to content

Fix (config): Read CACHE_LOCAL_TTL for the local cache TTL - #2760

Open
VitorCoelho wants to merge 1 commit into
evolution-foundation:developfrom
VitorCoelho:fix/cache-local-ttl
Open

VitorCoelho wants to merge 1 commit into
evolution-foundation:developfrom
VitorCoelho:fix/cache-local-ttl

Conversation

@VitorCoelho

@VitorCoelho VitorCoelho commented Oct 20, 2026 •

Copy link
Copy Markdown

📋 Description

CACHE.LOCAL.TTL in src/config/env.config.ts is parsed from CACHE_REDIS_TTL instead of CACHE_LOCAL_TTL:

LOCAL: {
  ENABLED: process.env?.CACHE_LOCAL_ENABLED === 'true',
  TTL: Number.parseInt(process.env?.CACHE_REDIS_TTL) || 86400,
},

That way, the CACHE_LOCAL_TTL variable documented in env.example is 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 read CACHE_LOCAL_TTL. The default (86400) is unchanged.

🔗 Related Issue

No existing issue; found while reading the config.

🧪 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

🧪 Testing

  • Checked that CACHE_LOCAL_TTL is now the only source of CACHE.LOCAL.TTL, which LocalCache uses as its default TTL (src/cache/localcache.ts)
  • No breaking changes introduced: setups without CACHE_LOCAL_TTL still get 86400

✅ Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings

Summary by Sourcery

Bug Fixes:

  • Read CACHE_LOCAL_TTL when configuring the local cache TTL, while preserving the existing 86400-second default.

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.
@sourcery-ai

sourcery-ai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes local cache TTL configuration to honor CACHE_LOCAL_TTL instead of incorrectly reusing CACHE_REDIS_TTL, preventing local entries from inheriting the Redis retention period while keeping the existing default behavior.

File-Level Changes

Change Details Files
Correct the environment-variable source used for the local cache TTL while preserving the existing fallback.
  • Read CACHE_LOCAL_TTL when configuring CACHE.LOCAL.TTL.
  • Retain the 86400-second default when the variable is absent or invalid.
src/config/env.config.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/config/env.config.ts

This branch has not been deployed

No deployments
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.

1 participant