1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Add unref() method to RedisClient that will call unref() on the socket connection, allowing it to close when unused. This is experimental because it does not yet understand the Redis protocol, so subscriptions or blocking operations will not work correctly.

This commit is contained in:
Bryce Baril
2013-10-02 16:10:26 -07:00
parent 5f125b51d4
commit b12c49a207
4 changed files with 64 additions and 0 deletions

View File

@@ -121,6 +121,20 @@ RedisClient.prototype.initialize_retry_vars = function () {
this.attempts = 1;
};
RedisClient.prototype.unref = function () {
trace("User requesting to unref the connection");
if (this.connected) {
trace("unref'ing the socket connection");
this.stream.unref();
}
else {
trace("Not connected yet, will unref later");
this.once("connect", function () {
this.unref();
})
}
};
// flush offline_queue and command_queue, erroring any items with a callback first
RedisClient.prototype.flush_and_error = function (message) {
var command_obj;