medea-clusterify

Adds support for the cluster core API.

npm install medea-clusterify
2 downloads in the last week
5 downloads in the last month

medea-clusterify

Add support for Node's cluster core API. Spawn many processes using only the master to access Medea.

This is an addon for Medea, the all-JavaScript key-value store.

Usage

Initialize

To add support for clusters, just clusterify Medea.

var Medea = require('medea');
var clusterify = require('medea-clusterify');

var MedeaCluster = clusterify(Medea);

var medea = new MedeaCluster();

Setup Master

To start cluster mode, run medea.setupMaster in the master process.

if (cluster.isMaster) {
  medea.setupMaster();

  // Go about your forking...
}

Using Medea from Worker Processes

To use Medea from worker processes, it's business as usual.

medea.open(function() {
  medea.get('favorite_nacho_topping', function(err, val) {
    console.log(val.toString()); // probably 'jalapenos'
  });
});

That's it!

Note that if you're doing a new require('medea') in worker processes, you may need to reclusterify.

License

MIT

npm loves you