node.js - AWS ioredis 与 Node js

标签 node.js amazon-web-services ioredis

我必须连接 AWS 中的 Redis 集群。任何人都可以指导如何使用ioredis和node js连接到redis集群。将有 1 个主人和 3 个奴隶。 提前致谢。

最佳答案

您可以首先阅读文档:"Access Patterns for Accessing an ElastiCache Cluster in an Amazon VPC"

正如您在文档中看到的,您的解决方案将取决于是否在同一 VPC 中运行。

连接问题解决后,您可以转到ioredis documentation ,您可以在那里看到一个非常简单的示例。

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);

关于node.js - AWS ioredis 与 Node js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51405338/

相关文章:

amazon-web-services - 从 Lambda 代码调用 AWS boto 函数

redis - 如果初始连接的集群节点死亡,ioredis 客户端能否继续工作?

typescript - 如何使用 `ioredis`中的Redis设置RedisService?

javascript - LAME 编码器 Node.js MP3 流

javascript - meteor 批量插入仅插入最后一项

javascript - WebSockets : useful for reducing overhead?

testing - 使用 NestJS 队列时关闭 redis 连接

node.js - Gulp:如何从流数组的 promise 创建流?

c# - 访问 S3FileInfo 属性时发生 AmazonS3Exception

android - 来自 Android 的所有 S3 调用都出现 504 错误