A Map subclass with TTL-based expiration for caching in Node.js (v0.1.1). It extends ES6 Map with optional per-key max age and automatic or manual trimming of expired entries. Supports proxy wrapping for memoization of async functions with cached results. Lightweight, no external dependencies required (except object-hash for proxy). Ideal for simple in-memory caching with fine-grained control over expiration.
npm install map-cache-ttlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: creating a cache with 5s default TTL and 1s auto-trim, setting a key with 10s TTL, checking existence, and using proxy to memoize a fetch call for 30s.
Maintain your own counter or use cache.has(key) for specific keys.
Use cache.trim() manually before reading size if you need precise counts without side effects.
Serialize mutable arguments to stable strings before passing to proxy.
Always provide an interval in constructor or call trim() periodically.
npm install map-cache-ttl. For ESM, use const Cache = require('map-cache-ttl') via createRequire.Use 'new Cache(...)'.
Use numbers: new Cache(5000) for 5 seconds.
No dependency data recorded yet.