Last active
August 29, 2015 14:21
-
-
Save dg3feiko/8f99da2fb2fd05dc3065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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