Skip to content

[JS] Add LRU cache support with maxSize option for getOptions#197

Merged
juharris merged 11 commits intomainfrom
claude/add-max-size-option-cache
Apr 7, 2026
Merged

[JS] Add LRU cache support with maxSize option for getOptions#197
juharris merged 11 commits intomainfrom
claude/add-max-size-option-cache

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Apr 6, 2026

Adds support for limiting cache size in JavaScript getOptions using LRU (Least Recently Used) eviction strategy.

Changes Made

  • Added lru-cache v11 as a production dependency
  • Created CacheInitOptions class for cache initialization configuration with optional maxSize parameter
  • Kept CacheOptions class empty as originally designed - acts as a marker class for enabling caching
  • LRU eviction: When maxSize is set via new CacheInitOptions(maxSize), an LRUCache is used instead of a plain Map — least recently used entries are evicted when the limit is reached
  • Unlimited cache: Using new CacheInitOptions() keeps the original unlimited behavior
  • Cache initialization: maxSize is set once when the cache is first created (when provider is built and first used), not on every request
  • Separation of concerns: CacheInitOptions handles cache configuration, while CacheOptions remains a simple marker class

API Usage

// With size limit (LRU cache)
const cacheInitOptions = new CacheInitOptions(100);
provider.getOptions('myKey', ['featureA'], MySchema, null, cacheInitOptions);

// Unlimited cache
const cacheInitOptions = new CacheInitOptions();
provider.getOptions('myKey', ['featureA'], MySchema, null, cacheInitOptions);

Testing

  • ✅ All 136 tests passing
  • ✅ Tests cover: cache option acceptance, unlimited cache behavior, and LRU eviction for both OptionsProvider and OptionsWatcher
  • ✅ TypeScript compilation passes
  • ✅ Build process completes successfully

@Claude Claude AI assigned Claude and nuharris Apr 6, 2026
@Claude Claude AI linked an issue Apr 6, 2026 that may be closed by this pull request
@Claude Claude AI changed the title [WIP] Add max size option when initializing the cache [JS][cache] Research LRU libraries for max size cache option Apr 6, 2026
@Claude Claude AI requested a review from nuharris April 6, 2026 12:59
Agent-Logs-Url: https://github.com/juharris/optify/sessions/f5db8430-2b64-46d5-b0ca-1ea72e6e3a16

Co-authored-by: nuharris <273340593+nuharris@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

@copilot use lru-cache. Just do the js folder

Done in commit b2c0500. Here's what was implemented in the JS folder:

  • Added lru-cache v11 as a production dependency
  • Extended CacheOptions with an optional maxSize constructor param: new CacheOptions({ maxSize: 100 })
  • When maxSize is set, an LRUCache is used instead of a plain Map — least recently used entries are evicted when the limit is reached
  • Omitting maxSize (or new CacheOptions()) keeps the original unlimited behavior

6 new tests cover acceptance of the option, unlimited cache behavior, and LRU eviction for both OptionsProvider and OptionsWatcher.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ofcncog2cu-dsn.algolia.net
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/yarn add lru-cache@^11.0.0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [JS][cache] Research LRU libraries for max size cache option [JS][cache] Add max size option using lru-cache Apr 6, 2026
Comment thread js/optify-config/src/caching.ts Outdated
@Claude Claude AI changed the title [JS][cache] Add max size option using lru-cache Addressing PR comments Apr 6, 2026
@Claude Claude AI requested a review from nuharris April 6, 2026 18:49
@nuharris
Copy link
Copy Markdown
Collaborator

nuharris commented Apr 6, 2026

@copilot why do you always fuck up the pull request title and change the description and nuke it whenever you start working on stuff. Get your fucking shit together. You fucking piece of shit

Comment thread js/optify-config/src/index.ts Outdated
Agent-Logs-Url: https://github.com/juharris/optify/sessions/b25dbdfa-d853-486a-a0e3-7fdf38110cce

Co-authored-by: nuharris <273340593+nuharris@users.noreply.github.com>
@Claude Claude AI requested a review from nuharris April 6, 2026 19:12
Comment thread js/optify-config/src/caching.ts Outdated
Comment thread js/optify-config/package.json
@Claude
Copy link
Copy Markdown
Contributor Author

Claude AI commented Apr 6, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr view --json title,number,body /home/REDACTED/.nvm/bash_completion /home/REDACTED/.nvm/install.sh /home/REDACTED/.nvm/nvm-exec /home/REDACTED/.nvm/nvm.sh /home/REDACTED/.nvm/package.json /home/REDACTED/.nvm/rename_test.sh /home/REDACTED/.nvm/test js/o�� js/optify-config/target/debug/deps/liquid_derive/home/REDACTED/work/optify/optify/js/optify-configbase64 js/optify-config/target/debug/deps/liquid_derive/home/REDACTED/work/optify/optify/js/optify-config-d /index.crates.io-1949cf8c6b5b557f/file-id-0.2.3//home/REDACTED/work/optify/optify/js/optify-config/target/debug/deps/napi_derive-bc2a4527cd1ed96d.napi_derive.5a5a479bb976b767-cgu.02.rcgu.o 0, length(NVM_DIsed artifacts,future-e d (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@Claude Claude AI changed the title Addressing PR comments [JS] Add LRU cache support with maxSize option for getOptions Apr 6, 2026
@Claude Claude AI requested a review from nuharris April 6, 2026 19:25
Comment thread js/optify-config/src/caching.ts Outdated
@Claude Claude AI requested a review from nuharris April 6, 2026 21:05
@juharris juharris marked this pull request as ready for review April 7, 2026 01:54
@juharris juharris merged commit 0a388f0 into main Apr 7, 2026
33 checks passed
@juharris juharris deleted the claude/add-max-size-option-cache branch April 7, 2026 02:16
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.

[JS][cache] Add max size option when initializing the cache

4 participants