【问题标题】:AWS ioredis with node js带有节点 js 的 AWS ioredis
【发布时间】:2018-12-26 13:40:32
【问题描述】:

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

【问题讨论】:

    标签: node.js amazon-web-services ioredis


    【解决方案1】:

    您可以从阅读文档开始:"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);
    

    【讨论】:

      猜你喜欢
      • 2017-08-08
      • 2014-12-19
      • 2020-05-22
      • 2019-01-31
      • 2016-08-26
      • 2016-12-06
      • 2019-04-01
      • 2018-01-20
      • 2016-12-06
      相关资源
      最近更新 更多