@cacheable/memory - docs: clarify that lruSize=0 disables LRU (fixes #1637)#1638
Merged
Conversation
…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.
Contributor
There was a problem hiding this comment.
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.
…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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
Summary
Fixes #1637.
The
@cacheable/memoryREADME describedlruSize: 0as "unlimited" in three places, but the JSDoc onCacheableMemoryOptions.lruSizeand the actual code say it disables the LRU cache. The code is authoritative:_lruSizedefaults to0, andlruAddToFront/lruMoveToFront/lruRemoveall early-return when_lruSize === 0, andset()only performs eviction when_lruSize > 0. So withlruSize: 0the LRU is off entirely — the cache is bounded only by the underlyingMapstores, 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:
lruSizealso setshashStoreSizeto1. The constructor (packages/memory/src/index.ts:79-94) never touches_storeHashSizewhenlruSizeis provided, so this is incorrect. Rewrote the paragraph to describe what actually happens (double-linked list + the2^24cap that emits anerrorevent when exceeded).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 testpasses (doc-only change; no code paths touched)CacheableMemoryOptions.lruSizeJSDocGenerated by Claude Code