Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 1.03 KB

README.md

File metadata and controls

52 lines (33 loc) · 1.03 KB

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