An ultra fast in-memory JavaScript cache library (~1.28KB gzipped) with near real-time cache expiry, suitable for Node.js and browser environments. Version 1.0.6 is the latest; the library is stable with no frequent updates. Key differentiators: tiny size, event-driven expiry notification, and support for CommonJS and ESM. Alternatives like node-cache or lru-cache are heavier.
npm install pure-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creating a cache instance, setting expiry listener, putting and getting a value, and handling expiry.
Set expiryCheckInterval to a value lower than your shortest TTL to ensure timely removal.
Call cache.dispose() to clear timers and listeners.
Use cache.off('expiry', handler) before dispose or use a one-time listener.Use import PureCache from 'pure-cache' or const PureCache = require('pure-cache').Run npm install pure-cache and ensure the import path is correct.
Create an instance: const cache = new PureCache({...}); cache.on(...).No dependency data recorded yet.