开发者

direct (non-tcp) connection to redis from nodejs

hello all

I looked at the at the redis-node-client source (relevant part is shown bellow) and I see that it connects to redis via the 'net' package, which is TCP based.

line 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;
};

I was wondering if there's a more direct client for redis, preferably via domain-sockets or something of that sort. Im using redis 开发者_运维知识库localy, as cache, without going over the wire so its unnecessary to encode/decode messages with TCP headers...

thank you


Unix Domain Socket support appears to have landed in Redis as of Nov 4th.

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

To connect to a Unix Domain Socket, you need to supply the pathname to net.createConnection. Maybe something like this in redis-node-client:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜