xache is a minimal auto-expiring, max-size cache for Node.js and browsers. Current stable version is 1.2.1, with infrequent releases focused on bug fixes. It provides a simple Map-like API with configurable maxSize and maxAge, removing oldest entries when the size limit is hit. Unlike more complex caches (e.g., node-cache or lru-cache), xache is extremely lightweight, has zero dependencies, and supports custom backing stores via a createMap option. It is ideal for scenarios requiring a no-frills in-memory cache with automatic expiry and size limits.
npm install xacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a cache with max 5 entries and 1 second expiry, demonstrates set/get, auto-expiry, and eviction on overflow.
Do not rely on precise timing; use for short-lived cache needs only.
Implement custom tracking via createMap or subclass.
Use strings for keys; coerce other types if necessary.
Use () => new Map() or return an object with .get, .set, .delete, .has, .clear, [Symbol.iterator], .size.
Run 'npm install xache' in your project root.
Use 'const Xache = require('xache')' for CommonJS or 'import Xache from 'xache' for ESM.Pass a function that returns a Map, e.g., createMap: () => new Map()
No dependency data recorded yet.