2010-11-16 72 views
1

你好全部
我看着redis-node-client源代碼(相關部分如下圖所示),我發現它通過'net'連接到redis,包,這是基於TCP。從nodejs直接(非tcp)連接到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報頭/解碼消息...

謝謝

回答

3

Unix域套接字支持出現在Redis的已經降落作爲十一月的4。

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

很好,謝謝 – deepblue 2010-11-23 22:21:02