A simple in-memory cache for Node.js with support for TTL and expiration callbacks. Version 0.2.0 is stable with no recent releases; it uses setTimeout for expiration. Unlike more feature-rich solutions (e.g., node-cache, lru-cache), it offers a minimal API: put, get, del, clear, size, and import/export. Its constructor allows multiple isolated cache instances. Note that all operations are synchronous, and hits/misses are only tracked in debug mode.
npm install memory-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic put/get, TTL with callback, cache expiration, and creating a separate Cache instance.
Enable debug mode: cache.debug(true); before checking hits/misses.
Do not rely on exact millisecond expiration for timing-critical use cases.
Pass skipDuplicates: true to preserve existing keys.
Consider alternatives like node-cache or lru-cache for active development.
Use const cache = require('memory-cache'); to get the default instance.Switch to CommonJS or use a dynamic import: const cache = await import('memory-cache'); (note: package is not ESM).Ensure the third argument is a number (time in ms).
No dependency data recorded yet.