feat: switch local cache to an interface #322
Merged
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.

Why
We've fallen too far behind on lru-cache. We previously decided to lock it @ 6.x in #170 because our use case couldn't pre-allocate all the data structures ahead of time efficiently.
But while reading the thread for that, I noticed the author has a ttl-cache: isaacs/node-lru-cache#208 (comment). This is much closer to our needs.
We essentially simulate a LRU cache by updating the TTL on each get: https://github.com/isaacs/ttlcache?tab=readme-ov-file#cachegetkey-updateageonget-checkageonget-ttl--
Because our TTL is short yet we require storing N caches this use case is more optimal.
Ref: ENG-18193
How
Switch to ttl-cache but only as a dev dependency, make exported API an interface so that consumers can choose between old lru-cache and ttl-cache.
Test Plan
Run all tests.