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

Fix excess memory consumption from Queue backing store.

Thanks to Gustaf Sjöberg.
This commit is contained in:
Matt Ranney
2011-02-11 00:12:00 -10:00
parent efadbc8582
commit 0f907401f0
3 changed files with 26 additions and 1 deletions

View File

@@ -1,6 +1,18 @@
Changelog Changelog
========= =========
## v0.5.4 - February 11, 2011
Fix excess memory consumption from Queue backing store.
Thanks to Gustaf Sjöberg.
## v0.5.3 - February 5, 2011
Fix multi/exec error reply callback logic.
Thanks to Stella Laurenzo.
## v0.5.2 - January 18, 2011 ## v0.5.2 - January 18, 2011
Fix bug where unhandled error replies confuse the parser. Fix bug where unhandled error replies confuse the parser.

View File

@@ -112,6 +112,8 @@ function RedisClient(stream, options) {
} }
self.send_command(command_obj.command, command_obj.args, command_obj.callback); self.send_command(command_obj.command, command_obj.args, command_obj.callback);
} }
self.offline_queue = new Queue();
// Even though items were shifted off, Queue backing store still uses memory until next add
}); });
this.stream.on("data", function (buffer_from_socket) { this.stream.on("data", function (buffer_from_socket) {
@@ -133,6 +135,14 @@ function RedisClient(stream, options) {
args[2](message); args[2](message);
} }
}); });
self.offline_queue = new Queue();
self.command_queue.forEach(function (args) {
if (typeof args[2] === "function") {
args[2](message);
}
});
self.command_queue = new Queue();
self.connected = false; self.connected = false;
self.emit("error", new Error(message)); self.emit("error", new Error(message));
@@ -183,6 +193,7 @@ RedisClient.prototype.connection_gone = function (why) {
args[2]("Server connection closed"); args[2]("Server connection closed");
} }
}); });
self.command_queue = new Queue();
// If this is a requested shutdown, then don't retry // If this is a requested shutdown, then don't retry
if (self.closing) { if (self.closing) {
@@ -229,6 +240,7 @@ RedisClient.prototype.return_error = function (err) {
if (this.subscriptions === false && this.command_queue.length === 0) { if (this.subscriptions === false && this.command_queue.length === 0) {
this.emit("idle"); this.emit("idle");
this.command_queue = new Queue();
} }
if (command_obj && typeof command_obj.callback === "function") { if (command_obj && typeof command_obj.callback === "function") {
@@ -255,6 +267,7 @@ RedisClient.prototype.return_reply = function (reply) {
if (this.subscriptions === false && this.command_queue.length === 0) { if (this.subscriptions === false && this.command_queue.length === 0) {
this.emit("idle"); this.emit("idle");
this.command_queue = new Queue();
} }
if (command_obj && !command_obj.sub_command) { if (command_obj && !command_obj.sub_command) {

View File

@@ -1,5 +1,5 @@
{ "name" : "redis", { "name" : "redis",
"version" : "0.5.3", "version" : "0.5.4",
"description" : "Redis client library", "description" : "Redis client library",
"author": "Matt Ranney <mjr@ranney.com>", "author": "Matt Ranney <mjr@ranney.com>",
"contributors": [ "contributors": [