UNPKG

node-hashtable

Version:

This is a simple hashtable, all written in node, to help you access and store your data over multiple workers or modules. It will provide the abstraction to access it through workers (cluster).

35 lines (21 loc) 593 B
var hashtable = require("./index.js"); var cluster = require("cluster"); var numCPUs = require('os').cpus().length; if (cluster.isMaster) { // Fork workers. for (var i = 0; i < 1; i++) { cluster.fork(); } hashtable.set("key", ["Yello"]); hashtable.add("key", "Blu"); hashtable.add("key", "Blac"); console.log( hashtable.createHash({test:1}) ); } if (cluster.isWorker) { hashtable.createKey(function(data) { console.log(data); }); hashtable.get("key", function(data) { console.log(data) }); }