nano-cache is a lightweight in-memory cache for Node.js (version 1.1.2, last updated 2018). It provides TTL, access-limit, and memory-limit based expiration with LRU eviction, compressed storage for higher capacity, and event emitters for cache operations. Unlike larger caches like node-cache or lru-cache, it focuses on simplicity and supports per-item TTL/limit overrides. It requires JSON-serializable values and emits events on get/set/del/clear. No breaking changes have been reported, but the package is in maintenance mode.
npm install nano-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a cache with a 60-second TTL and 10 MB memory limit, sets a key, retrieves it, and logs stats.
Ensure values are plain objects, strings, numbers, booleans, null, or arrays thereof.
Use `new NanoCache()` for isolated cache instances instead of the singleton.
Call `cache.removeAllListeners()` or use scoped listeners with `cache.off()`.
Consider migrating to actively maintained alternatives like lru-cache or node-cache.
Use `const cache = require('nano-cache'); cache.get('key');`Reduce the `bytes` value or use `NanoCache.SIZE.MB` to stay within limits.
Add `const NanoCache = require('nano-cache');` at the top of the file.No dependency data recorded yet.