Skip to content

@cacheable/memory - docs: clarify that lruSize=0 disables LRU (fixes #1637)#1638

Merged
jaredwray merged 2 commits into
mainfrom
claude/review-issue-1637-ceBXP
May 13, 2026
Merged

@cacheable/memory - docs: clarify that lruSize=0 disables LRU (fixes #1637)#1638
jaredwray merged 2 commits into
mainfrom
claude/review-issue-1637-ceBXP

Conversation

@jaredwray
Copy link
Copy Markdown
Owner

@jaredwray jaredwray commented May 13, 2026

Summary

Fixes #1637.

The @cacheable/memory README described lruSize: 0 as "unlimited" in three places, but the JSDoc on CacheableMemoryOptions.lruSize and the actual code say it disables the LRU cache. The code is authoritative: _lruSize defaults to 0, and lruAddToFront / lruMoveToFront / lruRemove all early-return when _lruSize === 0, and set() only performs eviction when _lruSize > 0. So with lruSize: 0 the LRU is off entirely — the cache is bounded only by the underlying Map stores, which is not what "unlimited LRU" would imply to a reader.

While fixing that I also corrected two adjacent doc bugs in the same section:

  • The "CacheableMemory LRU Feature" section claimed that setting lruSize also sets hashStoreSize to 1. The constructor (packages/memory/src/index.ts:79-94) never touches _storeHashSize when lruSize is provided, so this is incorrect. Rewrote the paragraph to describe what actually happens (double-linked list + the 2^24 cap that emits an error event when exceeded).
  • The LRU example's inline comment said lruSize: 1 "sets the LRU cache size to 1000 keys and hashStoreSize to 1" — neither was true. Corrected to "sets the LRU cache size to 1 key".

No code changes; documentation only.

Test plan

  • pnpm test passes (doc-only change; no code paths touched)
  • README renders correctly on GitHub
  • Wording aligns with CacheableMemoryOptions.lruSize JSDoc

Generated by Claude Code

…1637)

The README described lruSize=0 as "unlimited" while the JSDoc and code
say it disables the LRU cache. The code is authoritative: when
_lruSize === 0 the LRU helpers early-return and set() never evicts, so
"disabled" is the correct description.

Also corrected the LRU section's claim that setting lruSize auto-sets
hashStoreSize to 1 (the constructor never touches storeHashSize), and
fixed the example comment that said lruSize: 1 sets 1000 keys.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the documentation for CacheableMemory in packages/memory/README.md to clarify the behavior of the lruSize property, including its default value, maximum limit, and its independence from storeHashSize. Review feedback suggested minor grammatical improvements and the use of standard terminology like 'doubly linked list' through code suggestions.

Comment thread packages/memory/README.md Outdated
Comment thread packages/memory/README.md Outdated
…ed list)

Address two review suggestions on #1638:
- Add comma after introductory clause on the lruSize intro sentence and
  rephrase for readability.
- Use "doubly linked list" to match the internal DoublyLinkedList class.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7cbe243) to head (eece4a4).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1638   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        26           
  Lines         2497      2497           
  Branches       555       555           
=========================================
  Hits          2497      2497           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaredwray jaredwray merged commit 2abfb68 into main May 13, 2026
10 checks passed
@jaredwray jaredwray deleted the claude/review-issue-1637-ceBXP branch May 13, 2026 21:08
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.

conflicting information in docs regarding lruSize

2 participants