An LRU (least recently used) cache implementation compatible with Facebook's DataLoader. Version 1.0.1 is the current stable release; the package has not seen updates since 2017, reflecting a maintenance or deprecated state. It wraps the lru-cache module to provide bounded memory usage for DataLoader instances that persist across requests, such as in GraphQL contexts. Unlike the default Map cache, it evicts least recently used entries when the cache size limit is exceeded. Also supports clearing specific keys when records mutate. This package is specific to DataLoader and offers no alternative caching strategies.
npm install dataloader-cache-lruNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creation of an LRU cache with max size 3, using it with DataLoader, loading a key, and clearing it.
Use @types/dataloader-cache-lru if available, or declare module manually.
Consider alternatives like @keyv/lru or manual LRU using lru-cache directly.
If using custom cache, ensure it implements the CacheMap interface.
Refer to lru-cache documentation for options like max, maxAge, etc.
Use `const createCache = require('dataloader-cache-lru');` or `import createCache from 'dataloader-cache-lru';`Call createCache: `const cacheMap = createCache({ max: 100 });`Run `npm install lru-cache` as this package depends on it.
Use the cache object returned by createCache, which implements delete.