Skip to content

Instantly share code, notes, and snippets.

@dg3feiko
Last active August 29, 2015 14:21
Show Gist options
  • Save dg3feiko/8f99da2fb2fd05dc3065 to your computer and use it in GitHub Desktop.
Save dg3feiko/8f99da2fb2fd05dc3065 to your computer and use it in GitHub Desktop.
//npm install ioredis
//npm install bluebird
//change endpoint to any two of your clusters
var Redis = require('ioredis');
var Promise = require('bluebird');
var cluster = new Redis.Cluster([{
port: 30001,
host: '127.0.0.1'
}, {
port: 30008,
host: '127.0.0.1'
}]);
var counter = 0;
var set_value = Promise.coroutine(function *(){
while(true)
{
yield cluster.set("foo", counter++);
console.log("set foo", counter);
yield Promise.delay(1000);
};
})
set_value();
setInterval(function () {
cluster.get('foo', function (err, res) {
console.log("get foo:", err, res);
});
},1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment