A lightweight, zero-dependency in-memory cache for Node.js with TypeScript support. Version 3.0.0 provides a simple API for get, set, delete, and clear operations, with optional TTL (time-to-live) in seconds. It is ideal for caching API responses, session data, or memoizing function results. Unlike heavier alternatives like node-cache, it has no serialization overhead and no external dependencies, making it extremely fast and memory efficient.
npm install fast-memory-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates instantiation, set/get with and without TTL, delete, and clear operations in TypeScript.
Always pass TTL in seconds (e.g., 300 for 5 minutes). If you pass milliseconds (e.g., 5000), the value will expire after ~83 minutes instead of 5 seconds.
If you want a value to expire immediately, do not use this library—consider using a TTL of 1 second and immediately calling delete, or use a different approach.
Always check against undefined, not falsy. If your values can be null, treat them carefully.
Convert non-string keys to strings before calling set/get (e.g., JSON.stringify).
Run 'npm install fast-memory-cache' and ensure your tsconfig.json includes 'node_modules' in moduleResolution.
Use 'import MemoryCache from 'fast-memory-cache'' or in CJS: 'const MemoryCache = require('fast-memory-cache').default'.Instantiate with 'new MemoryCache()' before calling methods.
No dependency data recorded yet.