deepblue
deepblue

Reputation: 8596

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

Upvotes: 1

Views: 1174

Answers (1)

rjp
rjp

Reputation: 1958

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

Upvotes: 3

Related Questions