我必须连接在AWS中的redis集群。有人能指导如何使用ioredis和节点js连接到redis集群吗?会有一个主人和三个奴隶。提前感谢。
发布于 2018-07-18 16:54:49
您可以从阅读文档开始:“在Amazon中访问ElastiCache集群的访问模式”
正如您在文档中所看到的,您的解决方案将取决于是否在同一个VPC中运行。
一旦您的连接问题得到解决,您就可以转移到ioredis文档,您可以在那里看到一个非常简单的例子。
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
// Arguments to commands are flattened, so the following are the same:
redis.sadd('set', 1, 3, 5, 7);
redis.sadd('set', [1, 3, 5, 7]);
// All arguments are passed directly to the redis server:
redis.set('key', 100, 'EX', 10);https://stackoverflow.com/questions/51405338
复制相似问题