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

Merge branch 'select_db_exception' of https://github.com/roamm/node_redis into roamm-select_db_exception

This commit is contained in:
Bryce Baril
2013-03-26 21:47:09 -07:00
2 changed files with 28 additions and 2 deletions

View File

@@ -285,7 +285,12 @@ RedisClient.prototype.on_ready = function () {
// magically restore any modal commands from a previous connection
if (this.selected_db !== null) {
// this trick works if and only if the following send_command
// never goes into the offline queue
var pub_sub_mode = this.pub_sub_mode;
this.pub_sub_mode = false;
this.send_command('select', [this.selected_db]);
this.pub_sub_mode = pub_sub_mode;
}
if (this.pub_sub_mode === true) {
// only emit "ready" when all subscriptions were made again
@@ -494,8 +499,8 @@ RedisClient.prototype.return_error = function (err) {
var command_obj = this.command_queue.shift(), queue_len = this.command_queue.getLength();
if (this.pub_sub_mode === false && queue_len === 0) {
this.emit("idle");
this.command_queue = new Queue();
this.emit("idle");
}
if (this.should_buffer && queue_len <= this.command_queue_low_water) {
this.emit("drain");
@@ -585,8 +590,8 @@ RedisClient.prototype.return_reply = function (reply) {
queue_len = this.command_queue.getLength();
if (this.pub_sub_mode === false && queue_len === 0) {
this.emit("idle");
this.command_queue = new Queue(); // explicitly reclaim storage from old Queue
this.emit("idle");
}
if (this.should_buffer && queue_len <= this.command_queue_low_water) {
this.emit("drain");