An in-memory TTL key/value cache with streaming support. Current stable version is 4.1.0. It does not proactively prune expired items; instead, items expire when touched, avoiding setTimeout overhead. There is no maximum item limit, making it suitable for small to medium datasets. Key differentiators include per-item TTL, stale data delivery option, change event streaming via a Duplex stream, and an optional instance ID for origin tracking. It is a Node.js-only library, not browser-compatible.
npm install ttl-mem-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic instantiation with TTL options, setting/getting values, and stale mode behavior.
Update instantiation to new Cache({ ttl: ... }) instead of new Cache(ttl, stale).Replace cache.remove(key) with cache.del(key).
Periodically call .get() or .entries() to trigger pruning, or implement a separate cleanup loop.
If using stream mode, ensure you consume the readable side or handle backpressure properly.
Use a sufficiently large number (e.g., Number.MAX_SAFE_INTEGER) if you want a clear expiration boundary.
Use default import: const Cache = require('ttl-mem-cache'); or import Cache from 'ttl-mem-cache';Instantiate first: const cache = new Cache(); then cache.set(key, value);
Use import Cache from 'ttl-mem-cache'; instead of require.
No dependency data recorded yet.