lru-cache-idb v0.5.2 is an LRU cache for web applications backed by IndexedDB. It batches writes to reduce I/O (default write interval 15s), batches eviction (default 1 min), and optionally keeps a subset of items in memory for faster reads. Designed for multi-tab safety and cross-session persistence, it implements a modern LRU eviction policy. Unlike most LRU caches (e.g., lru-cache for Node), lru-cache-idb is browser-first, uses no third-party dependencies, and is fully typed in TypeScript as an ESM-only module. Developed with low-frequency updates, it is stable for use cases requiring persistent client-side cache.
npm install lru-cache-idbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates an LRU cache with IndexedDB persistence, sets and gets an object item, logs it, deletes it, and clears the cache.
Configure a shorter writeIntervalMs in the options, or call .flush() explicitly before navigating away.
Set a shorter evictionIntervalMs or call .evict() manually if memory constraints are strict.
Update imports: use `import { createCacheIdb } from 'lru-cache-idb'` instead of `import createCacheIdb from 'lru-cache-idb'`.Specify a unique `database` option per cache instance.
Replace `import createCacheIdb from 'lru-cache-idb'` with `import { createCacheIdb } from 'lru-cache-idb'`.Ensure `const cache = await createCacheIdb(...)` and wait for initialization before calling cache methods.
Use unique database names per page instance, and avoid concurrent destructive operations.
No dependency data recorded yet.