A simple Node.js module to persistently store/cache arbitrary data to disk with optional memory mirroring for performance. Version 1.1.2 (latest) has low release activity with no recent updates. It provides both synchronous and asynchronous APIs for get, put, delete, and keys operations. Data is stored as files on disk, and cache entries can have a time-to-live duration. It is lightweight with no dependencies, but offers basic functionality compared to more feature-rich caching libraries like node-cache or lru-cache. Suitable for simple persistent storage needs, but has known issues with path handling and race conditions on concurrent access.
npm install persistent-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: create cache with options, put/get data asynchronously and synchronously, list keys, delete entries, and unlink the entire cache.
Use a caching library designed for concurrency (e.g., redis, lru-cache with disk persistence) or implement file locking.
Always specify an explicit base option pointing to a writable path.
Call persistentCache(options) without the 'new' keyword.
Wrap calls in try-catch or use promise wrappers. Consider using synchronous methods for simplicity.
Ensure the base directory exists before creating a cache instance.
Verify the base and name options, ensure the directory is writable, and recreate the cache if necessary.
Create the cache using persistentCache(options) without the 'new' keyword.
Ensure data passed to put is serializable (no circular references, no functions).
Run 'npm install persistent-cache' in your project directory.
No dependency data recorded yet.