@@ -4,6 +4,7 @@ var net = require('net');
4
4
var tls = require ( 'tls' ) ;
5
5
var util = require ( 'util' ) ;
6
6
var utils = require ( './lib/utils' ) ;
7
+ var Command = require ( './lib/command' ) ;
7
8
var Queue = require ( 'double-ended-queue' ) ;
8
9
var errorClasses = require ( './lib/customErrors' ) ;
9
10
var EventEmitter = require ( 'events' ) ;
@@ -154,7 +155,6 @@ function RedisClient (options, stream) {
154
155
this . times_connected = 0 ;
155
156
this . buffers = options . return_buffers || options . detect_buffers ;
156
157
this . options = options ;
157
- this . old_state = { } ;
158
158
this . reply = 'ON' ; // Returning replies is the default
159
159
// Init parser
160
160
this . reply_parser = create_parser ( this ) ;
@@ -445,10 +445,10 @@ RedisClient.prototype.on_ready = function () {
445
445
446
446
// Restore modal commands from previous connection. The order of the commands is important
447
447
if ( this . selected_db !== undefined ) {
448
- this . select ( this . selected_db ) ;
448
+ this . internal_send_command ( new Command ( 'select' , [ this . selected_db ] ) ) ;
449
449
}
450
- if ( this . old_state . monitoring ) { // Monitor has to be fired before pub sub commands
451
- this . monitor ( ) ;
450
+ if ( this . monitoring ) { // Monitor has to be fired before pub sub commands
451
+ this . internal_send_command ( new Command ( 'monitor' , [ ] ) ) ;
452
452
}
453
453
var callback_count = Object . keys ( this . subscription_set ) . length ;
454
454
if ( ! this . options . disable_resubscribing && callback_count ) {
@@ -571,12 +571,6 @@ RedisClient.prototype.connection_gone = function (why, error) {
571
571
this . cork = noop ;
572
572
this . uncork = noop ;
573
573
this . pipeline = false ;
574
-
575
- var state = {
576
- monitoring : this . monitoring
577
- } ;
578
- this . old_state = state ;
579
- this . monitoring = false ;
580
574
this . pub_sub_mode = 0 ;
581
575
582
576
// since we are collapsing end and close, users don't expect to be called twice
@@ -874,16 +868,16 @@ RedisClient.prototype.internal_send_command = function (command_obj) {
874
868
var big_data = false ;
875
869
var args_copy = new Array ( len ) ;
876
870
877
- if ( process . domain && command_obj . callback ) {
878
- command_obj . callback = process . domain . bind ( command_obj . callback ) ;
879
- }
880
-
881
871
if ( this . ready === false || this . stream . writable === false ) {
882
872
// Handle offline commands right away
883
873
handle_offline_command ( this , command_obj ) ;
884
874
return false ; // Indicate buffering
885
875
}
886
876
877
+ if ( process . domain && command_obj . callback ) {
878
+ command_obj . callback = process . domain . bind ( command_obj . callback ) ;
879
+ }
880
+
887
881
for ( i = 0 ; i < len ; i += 1 ) {
888
882
if ( typeof args [ i ] === 'string' ) {
889
883
// 30000 seemed to be a good value to switch to buffers after testing and checking the pros and cons
0 commit comments