Overview
The current cache evicts entries only by TTL. Under high usage with many unique keys, the cache grows unbounded until TTL expires. Add LRU (Least Recently Used) eviction to cap memory usage.
Acceptance Criteria
StellarSplitSDK({ cache: { maxEntries: 500 } }) config option
- When
maxEntries is reached, the least recently accessed entry is evicted before adding a new one
- LRU order updated on every cache hit (read counts as access)
sdk.getCacheStats() adds evictions: number to the existing stats
- LRU and TTL work together: an entry can be evicted by either mechanism
maxEntries defaults to 1000 when cache is enabled; 0 means no LRU cap
- Implementation uses a
Map + doubly-linked list for O(1) get/put
- Unit tests: fill cache to maxEntries + 1, verify oldest entry evicted; verify LRU order respected
Overview
The current cache evicts entries only by TTL. Under high usage with many unique keys, the cache grows unbounded until TTL expires. Add LRU (Least Recently Used) eviction to cap memory usage.
Acceptance Criteria
StellarSplitSDK({ cache: { maxEntries: 500 } })config optionmaxEntriesis reached, the least recently accessed entry is evicted before adding a new onesdk.getCacheStats()addsevictions: numberto the existing statsmaxEntriesdefaults to 1000 when cache is enabled; 0 means no LRU capMap+ doubly-linked list for O(1) get/put