A simple Node.js cache object that wraps a promise-returning function and caches the resolved value for a configurable TTL. Version 1.0.1 (latest) with no active development. Uses an LRU cache under the hood with configurable max size and max age. Useful for memoizing async operations like API calls or database queries. Minimal API with get, set, and clear methods. Limited documentation, no TypeScript types, CommonJS only.
npm install zb-promise-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a PromiseCache instance with options, using get() to fetch/cache, and clear() to reset.
Use unique cache keys per unique input, or handle cache invalidation manually.
Always wrap params in an array: cache.get('key', [value]) even for single argument.Use require() or use a dynamic import with createRequire.
Add a custom .d.ts file or use @ts-ignore.
Use const PromiseCache = require('zb-promise-cache');Use const cache = new PromiseCache(fn, opts);