Fast LRU (Least Recently Used) and TTL (Time-To-Live) cache implementation with upsert and promise support. Current stable version is 2.4.8, actively maintained. Key differentiators: supports both LRU eviction and TTL expiration simultaneously, built-in upsert (insert or update) operations, and promise-based async value resolution. Lightweight, zero dependencies, TypeScript type definitions included. Suitable for in-memory caching in Node.js and browser environments where both access pattern and expiration control are needed.
npm install lru-ttl-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic cache operations: creation with maxSize and ttl, set, get, upsert with async function, has, delete, and clear.
Always pass an options object with at least maxSize or ttl.
Use 'ttl' instead of 'maxAge'.
There is no direct method to get the count. Consider maintaining your own counter if needed.
If you need deduplication, implement your own locking or use an external library.
If you need per-key TTL, consider a different cache library or implement a wrapper.
Use named import: import { LRUTTLCache } from 'lru-ttl-cache'Use 'new LRUTTLCache(options)' instead of calling it as a function.
Run 'npm install lru-ttl-cache' and ensure import statement is correct.
No dependency data recorded yet.