Simple in-memory object cache with per-item TTL (time-to-live) expiry. Version 1.0.2 is the latest stable release, with infrequent updates. Key differentiators: lightweight, zero dependencies, simple API. Suitable for small-scale caching needs where a full-featured cache like node-cache or lru-cache is overkill.
npm install ttl-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a TTL cache with 60-second expiry, sets and retrieves a value, then shows expiration after timeout.
Pass TTL in seconds (e.g., 300 for 5 minutes).
Manually call `cache.purge()` to remove expired items proactively.
Install @types/ttl-cache or define your own types.
Run `npm install ttl-cache` or `yarn add ttl-cache`.
Use import TTLCache from 'ttl-cache'.
Set a positive ttl value in constructor options.
No dependency data recorded yet.