A lightweight, secure in-memory cache library for Node.js and browsers, currently at version 3.0.0. It limits the number of stored items without using JavaScript's `delete` operator to avoid memory leaks and hidden class changes, and instead uses a bucket-based eviction strategy that removes the oldest bucket when full. It is immune to prototype poisoning attacks via malicious keys like `__proto__` and avoids individual timeout timers per cached item. Main differentiators include defensive coding against prototype pollution, gradual memory freeing, and minimal overhead.
npm install safe-memory-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a cache with a limit of 100 items and a 60-second TTL, then set, get, and clear a key.
Use `import { safeMemoryCache } from 'safe-memory-cache'` instead of `import safeMemoryCache from ...`.Avoid using `cleanupListener` and `retainUsed`; no direct replacement yet.
Set maxTTL at creation; items may be removed earlier if cache is full.
Always provide `{ limit: number }` when calling `safeMemoryCache`.Run `npm install safe-memory-cache` and ensure import uses correct name.
Use `import { safeMemoryCache } from 'safe-memory-cache'`.Call `safeMemoryCache({ limit: 100 })` with a valid limit.No dependency data recorded yet.