In-memory LRU cache with TTL support for Node.js and browsers. Current stable version is 1.3.2, released under an MIT license with a stable API. It provides a simple API similar to Map but with LRU eviction and per-key TTL, optional refresh on access, and built-in serialization/deserialization to JSON. Differentiates from libraries like lru-cache by its smaller footprint, TypeScript type definitions, and more straightforward API without external dependencies.
npm install receptacleNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a cache with max 100 items, sets a key with TTL 1 second, retrieves it, checks existence, deletes, clears, and demonstrates serialize/deserialize.
Change new Receptacle(100) to new Receptacle({ max: 100 }).Access metadata via cache.get(key) and store it in the value itself.
Call cache.has(key) before cache.get(key) if you need to distinguish between missing keys and stored undefined.
Call cache.clearExpired() before serializing (if available) or manually remove expired entries.
Always use cache.get(key) to trigger refresh on access.
Use 'import Receptacle from "receptacle"' for ESM or 'const Receptacle = require("receptacle")' for CommonJS.Pass an options object: new Receptacle({ max: 100 })Use default import: import Receptacle from 'receptacle'
Always instantiate with 'new': const cache = new Receptacle(...)
No dependency data recorded yet.