A lightweight promise-based cache for async functions with optional LRU eviction and configurable TTL. Current stable version is 1.0.2, released in 2018 with no recent updates. Key differentiators: simple API wrapping any async function, supports LRU via maxSize option, custom argument serialization. Works with both async and sync functions. Minimal dependencies; suitable for Node.js and browser environments.
npm install await-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates wrapping an async fetch function with 5-second TTL cache.
Provide a custom serialize function in options if using non-serializable arguments.
Understand eviction priorities: expiration first, then LRU.
Wrap function to catch and rethrow if you want error caching behavior.
Consider alternatives like lru-cache or async-cache-dedupe for active development.
const cachify = require('await-cache');Use dynamic import: const cachify = (await import('await-cache')).default; or use bundler.Cache the result of cachify and call it: const cached = cachify(...); cached().then(...);
No dependency data recorded yet.