Registry / database / simple-cluster-cache

simple-cluster-cache

JSON →
library0.0.6jsnpmunverified

simple-cluster-cache is a dead-simple in-memory cache for Node.js cluster applications, enabling shared caching between master and worker processes via IPC. Version 0.0.6 is the latest release. It provides basic get/set/del/clear methods with optional TTL and callback support, and supports both single-key and multi-key operations. It is designed specifically for the Node.js cluster module and does not require external dependencies like Redis or Memcached. The package has not seen updates since its initial release and has limited adoption.

npm install simple-cluster-cache
INSTALL
IMPORT
SIG · SIMPLE-CLUSTER-CAC
S
simple-cluster-cache
databasejavascriptv0.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (cache object)
import cache from 'simple-cluster-cache';
const cache = require('simple-cluster-cache');
ESM import is available; the package also supports CommonJS require.
cache.get
cache.get('key', callback);
cache.get('key');
Callback is optional for get, but without it the value is not returned; use callback to retrieve the value.
cache.set
cache.set('key', value, ttl, callback);
cache.set('key', value);
TTL and callback are optional; if omitted, the cache entry lives indefinitely and no callback is called.

Sets a cache entry in the master process and retrieves it in a worker process, demonstrating shared cache across cluster.

import cluster from 'cluster'; import cache from 'simple-cluster-cache'; if (cluster.isMaster) { cache.set('msg', 'Hello from master'); cluster.fork(); } else { cache.get('msg', (err, value) => { console.log(value); // 'Hello from master' }); }
Debug
Known issues
gotchaget method call without a callback does not return the value synchronously.
fix
Always provide a callback to retrieve the cached value. cache.get('key', (err, val) => { console.log(val); });
affects: >=0.0.0
deprecatedThe package has no recent updates and may not work with newer Node.js versions (e.g., ESM support, cluster module changes).
fix
Consider using a maintained alternative like node-cache-manager or built-in cluster IPC.
affects: >=0.0.0
gotchaWhen using multi get, the returned value is an object mapping keys to values, not an array.
fix
Handle the result as an object: cache.get(['key1', 'key2'], (err, result) => { console.log(result.key1); });
affects: >=0.0.0
Errors
Common errors & fixes
Error: cache.get is not a function
Using import incorrectly, e.g., importing named exports instead of default export.
fix
Use default import: import cache from 'simple-cluster-cache';
TypeError: callback is not a function
Calling get/set without a callback but expecting the value returned.
fix
Provide a callback function as the last argument: cache.get('key', (err, val) => {});
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
Meta
2
Resources
simple-cluster-cache — npm install simple-cluster-cache · libregistry