Extended version of Isaac's lru-cache 2.5.0. Adds per-item expiration (TTL) support via set(key, value, maxAge) and get() respects individual maxAge. Core LRU behavior retained: max size, length function, dispose callback, stale options, and forEach/keys/values iteration. Synchronous, zero dependencies, CommonJS only. Version 2.5.0 is stable but unmaintained; use the newer 'lru-cache' package (v4+) for continued updates and ESM support.
npm install lru-cache-plusNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates LRU creation with max and maxAge, setting items with per-item TTL, retrieving items (including stale handling), and iterating/resetting cache.
Replace with 'lru-cache' (npm package) and adapt API (e.g., options are constructor-based, use cache.set(key, value, options) with ttl in ms).
Wrap re-insertion in process.nextTick(() => cache.set(key, value)) or setTimeout.
Set stale: true to return stale value before deletion, or rely on periodic get() calls.
Call as LRU(options) or LRU(maxNumber), never with 'new'.
Change to 'LRU(options)' without 'new'.
Use 'const LRU = require('lru-cache-plus')' instead of ESM import.Provide custom length function, e.g., length: (n) => JSON.stringify(n).length.
No dependency data recorded yet.