【问题标题】:direct (non-tcp) connection to redis from nodejs从nodejs直接(非tcp)连接到redis
【发布时间】:2011-05-10 14:43:25
【问题描述】:

大家好
我查看了 redis-node-client 源(相关部分如下所示),我看到它通过基于 TCP 的“net”包连接到 redis。

第 370 行

exports.createClient = function (port, host, options) {
var port = port || exports.DEFAULT_PORT;
var host = host || exports.DEFAULT_HOST;

var client = new Client(net.createConnection(port, host), options);

client.port = port;
client.host = host;

return client;
};

我想知道是否有更直接的 redis 客户端,最好是通过域套接字或类似的东西。我使用 redis localy 作为缓存,无需通过网络,因此无需使用 TCP 标头对消息进行编码/解码...

谢谢

【问题讨论】:

    标签: node.js redis


    【解决方案1】:

    Unix 域套接字支持似乎已于 11 月 4 日登陆 Redis。

    http://code.google.com/p/redis/issues/detail?id=231

    要连接到 Unix 域套接字,您需要提供 net.createConnection 的路径名。在 redis-node-client 中可能是这样的:

    exports.createSocketClient = function (path, options) {
      var client = new Client(net.createConnection(path), options);
      client.path = path;
      return client;
    };
    

    【讨论】:

      猜你喜欢
      • 2019-12-21
      • 1970-01-01
      • 2018-09-29
      • 2015-01-12
      • 1970-01-01
      • 2021-09-05
      • 1970-01-01
      • 2022-06-24
      • 2012-08-15
      相关资源
      最近更新 更多