A simple Node.js module that mimics the LocalStorage API, persisting data to a JSON file between application launches. Version 0.1.4 is the latest stable release. The library aggregates write operations and flushes to disk once per second, ensuring data is saved on process exit. It supports optional in-memory-only mode (without file caching). Differentiator: lightweight, no external dependencies, and familiar API for developers coming from browser LocalStorage.
npm install node-localcacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: creating a cache instance backed by a JSON file, setting, getting, and removing items.
Always provide a file path or explicitly set skipFileCaching: true for in-memory only.
Avoid using in high-concurrency production environments; consider alternatives like node-persist or lowdb.
Use graceful shutdown or call a hypothetical flush method (not provided). Mitigate by reducing interval or using synchronous writes.
Use CommonJS require() as shown in the README.
const cache = new LocalCache('file.json');Provide a file path: new LocalCache('./cache.json');Use a bundler like webpack, or import via script tag with a CommonJS-compatible loader.
No dependency data recorded yet.