let Redis = require('ioredis');
let redisClusterHost='172.26.211.61 1379 Devper4mance 172.26.211.62 1379 Devper4mance 172.26.211.63 1379 Devper4mance 172.26.211.61 2379 Devper4mance 172.26.211.62 2379 Devper4mance 172.26.211.61 2379 Devper4mance';
let keys=['host', 'port','password'];
let redisClusterHostConfig = redisClusterHost.split(' ');
let redisClusterHostData = [];
for(var i=0; i < redisClusterHostConfig.length; i += keys.length){
    redisClusterHostData.push({"host":redisClusterHostConfig[i],"port":redisClusterHostConfig[i+1]});
}
console.log("Redis Cluster =>",redisClusterHostData)
console.log("Without Password with Redis Cluster")
client = new Redis.Cluster(redisClusterHostData);
//connect Client with Redis
client.on('connect', function() {
    console.log('Redis connected.');
});

let key = 'testfromscript';
let data ='CSK will win by Mahesh'
//Set data into redis key
client.setKey = function(key,data){
        client.set(key,data, function(error, result){
        });
}
//get data from Redis Key
client.getKey = function(key){
	client.get(key,function(err,result){
		if(!err){
			console.log ("Key retrieved from cache: " + key + result);
		}
	});
}
