Skip to content

fix: bound in-memory cache size - #199

Open
WilliamK112 wants to merge 2 commits into
pavanvamsi3:mainfrom
WilliamK112:agent/bound-cache-size
Open

fix: bound in-memory cache size#199
WilliamK112 wants to merge 2 commits into
pavanvamsi3:mainfrom
WilliamK112:agent/bound-cache-size

Conversation

@WilliamK112

Copy link
Copy Markdown

Summary

  • cap the in-memory TTL cache at 500 entries
  • evict the oldest inserted key before adding a new key at capacity
  • preserve existing entries when an expired key is recomputed in place
  • test the size bound, deterministic eviction, and recomputation behavior

Why

The cache used an unbounded Map, so distinct search and analytics keys could accumulate for the lifetime of the process. A simple FIFO cap keeps memory usage bounded while preserving the existing TTL and recomputation contracts.

Validation

  • npx vitest run src/__tests__/cache.test.ts (10 passed)
  • npm test (123 passed)
  • npm run typecheck
  • npm run build
  • git diff --check

Closes #181

AI-assisted: Codex was used to help implement and validate this change; the final diff and tests were reviewed locally.

Signed-off-by: WilliamK112 <164879897+WilliamK112@users.noreply.github.com>
@WilliamK112
WilliamK112 marked this pull request as ready for review August 12, 2026 11:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d61b1e9ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/__tests__/cache.test.ts Outdated
Signed-off-by: WilliamK112 <164879897+WilliamK112@users.noreply.github.com>
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.

Add max-size eviction to cache.ts to prevent unbounded memory growth

1 participant