A cluster-aware wrapper for node-cache that synchronizes an in-memory cache across Node.js cluster workers. Current version 0.1.5 (last release April 2018) wraps node-cache v1.x and does not support v2.0. Designed for simple, fast internal caching without external dependencies like Redis. The main differentiator is transparent cache synchronization in clustered Node.js applications, using IPC between master and worker processes. The API mirrors node-cache but returns Promises (or callbacks) for all operations. Note: this package is in maintenance mode and has limited TTL and checkperiod options compared to node-cache v2.
npm install cluster-node-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic initialization with cluster module and set/get in both master and worker processes.
Pin node-cache to v1.1.0 or earlier in your package.json: "node-cache": "~1.1.0".
Use .then() or async/await to access results. Check result.err for errors.
Initialize cache in the master process or at the top level of the entry point before any cluster.fork() calls.
Avoid using the CLS option. If you need context propagation, consider alternatives like async_hooks.
Access the cached value via result.value[key] or iterate over result.value.
Replace `require('cluster-node-cache')` with `require('cluster-node-cache')(cluster)`.Downgrade node-cache to v1.x: `npm install node-cache@~1.1.0`.
Ensure `var cluster = require('cluster');` is called before the factory invocation.