7

ElastiCache is not recommended to be accessed outside Amazon instancesということを知っています。そのため、以下ではAmazon EC2インスタンスの中でのみ以下のことを試しています。node.jsを使用してElastiCacheクラスターに接続する方法

ElastiCache Redis Clusterにはノードが9つあります。 normal redis implementationを使用して接続しようとすると、some Moved errors

となります。retry strategy method@Millerとして試してみました。またRedisClusterunstablestable (poor man)の実装で試したことがあります。

これらの実装は動作していません。何か提案してください?将来の読者のための

答えて

9

Sharing the code

var RedisClustr = require('redis-clustr'); 
var RedisClient = require('redis'); 
var config = require("./config.json"); 

var redis = new RedisClustr({ 
    servers: [ 
     { 
      host: config.redisClusterHost, 
      port: config.redisClusterPort 
     } 
    ], 
    createClient: function (port, host) { 
     // this is the default behaviour 
     return RedisClient.createClient(port, host); 
    } 
}); 

//connect to redis 
redis.on("connect", function() { 
    console.log("connected"); 
}); 

//check the functioning 
redis.set("framework", "AngularJS", function (err, reply) { 
    console.log("redis.set " , reply); 
}); 

redis.get("framework", function (err, reply) { 
    console.log("redis.get ", reply); 
}); 
関連する問題