1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +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

18
test.js
View File

@@ -10,6 +10,7 @@ var redis = require("./index"),
assert = require("assert"),
crypto = require("crypto"),
util = require("./lib/util"),
fork = require("child_process").fork,
test_db_num = 15, // this DB will be flushed and used for testing
tests = {},
connected = false,
@@ -2013,6 +2014,23 @@ tests.reconnectRetryMaxDelay = function() {
});
};
tests.unref = function () {
var name = "unref";
var external = fork("./test-unref.js");
var done = false;
external.on("close", function (code) {
assert(code == 0, "test-unref.js failed");
done = true;
})
setTimeout(function () {
if (!done) {
external.kill();
}
assert(done, "test-unref.js didn't finish in time.");
next(name);
}, 100);
};
all_tests = Object.keys(tests);
all_start = new Date();
test_count = 0;