@@ -55,9 +55,14 @@ function RedisClient (options) {
55
55
this . connection_id = ++ connection_id ;
56
56
this . connected = false ;
57
57
this . ready = false ;
58
- this . connections = 0 ;
59
58
if ( options . socket_nodelay === undefined ) {
60
59
options . socket_nodelay = true ;
60
+ } else if ( ! options . socket_nodelay ) { // Only warn users with this set to false
61
+ console . warn (
62
+ 'node_redis: socket_nodelay is deprecated and will be removed in v.3.0.0.\n' +
63
+ 'Setting socket_nodelay to false likely results in a reduced throughput. Please use .batch to buffer commands and use pipelining.\n' +
64
+ 'If you are sure you rely on the NAGLE-algorithm you can activate it by calling client.stream.setNoDelay(false) instead.'
65
+ ) ;
61
66
}
62
67
if ( options . socket_keepalive === undefined ) {
63
68
options . socket_keepalive = true ;
@@ -730,34 +735,31 @@ RedisClient.prototype.send_command = function (command, args, callback) {
730
735
this . writeDefault = this . writeBuffers ;
731
736
}
732
737
}
733
- } else if ( args [ i ] === null ) {
734
- if ( ! this . options . to_empty_string ) { // > 2 // ( 2 + 3 where 3 stands for both, null and undefined and 3 for null)
738
+ } else if ( typeof args [ i ] === 'object' ) { // Checking for object instead of Buffer.isBuffer helps us finding data types that we can't handle properly
739
+ if ( args [ i ] instanceof Date ) { // Accept dates as valid input
740
+ args [ i ] = args [ i ] . toString ( ) ;
741
+ // Add this to parse_arguments.
742
+ } else if ( args [ i ] === null ) {
735
743
console . warn (
736
744
'node_redis: Deprecated: The %s command contains a "null" argument.\n' +
737
745
'This is converted to a "null" string now and will return an error from v.3.0 on.\n' +
738
- 'If you wish to convert null to an empty string instead, please use the "to_empty_string" option .' , command . toUpperCase ( )
746
+ 'Please handle this in your code to make sure everything works as you intended it to behave .' , command . toUpperCase ( )
739
747
) ;
740
748
args [ i ] = 'null' ; // Backwards compatible :/
741
749
} else {
742
- args [ i ] = '' ;
743
- }
744
- } else if ( typeof args [ i ] === 'object' ) { // Buffer.isBuffer(args[i])) {
745
- buffer_args = true ;
746
- if ( this . pipeline !== 0 ) {
747
- this . pipeline += 2 ;
748
- this . writeDefault = this . writeBuffers ;
749
- }
750
- } else if ( args [ i ] === undefined ) {
751
- if ( ! this . options . to_empty_string ) {
752
- console . warn (
753
- 'node_redis: Deprecated: The %s command contains a "undefined" argument.\n' +
754
- 'This is converted to a "undefined" string now and will return an error from v.3.0 on.\n' +
755
- 'If you wish to convert undefined to an empty string instead, please use the "to_empty_string" option.' , command . toUpperCase ( )
756
- ) ;
757
- args [ i ] = 'undefined' ; // Backwards compatible :/
758
- } else {
759
- args [ i ] = '' ;
750
+ buffer_args = true ;
751
+ if ( this . pipeline !== 0 ) {
752
+ this . pipeline += 2 ;
753
+ this . writeDefault = this . writeBuffers ;
754
+ }
760
755
}
756
+ } else if ( typeof args [ i ] === 'undefined' ) {
757
+ console . warn (
758
+ 'node_redis: Deprecated: The %s command contains a "undefined" argument.\n' +
759
+ 'This is converted to a "undefined" string now and will return an error from v.3.0 on.\n' +
760
+ 'Please handle this in your code to make sure everything works as you intended it to behave.' , command . toUpperCase ( )
761
+ ) ;
762
+ args [ i ] = 'undefined' ; // Backwards compatible :/
761
763
}
762
764
}
763
765
@@ -903,11 +905,10 @@ RedisClient.prototype.end = function (flush) {
903
905
// Flush queue if wanted
904
906
if ( flush ) {
905
907
this . flush_and_error ( new Error ( "The command can't be processed. The connection has already been closed." ) ) ;
906
- } else if ( flush === undefined ) {
908
+ } else if ( arguments . length === 0 ) {
907
909
console . warn (
908
- 'node_redis: Using .end() without the flush parameter is deprecated. ' +
909
- 'Please check the doku (https://github.com/NodeRedis/node_redis) and explictly use flush.\n' +
910
- 'This will throw from v.3.0.0 on.'
910
+ 'node_redis: Using .end() without the flush parameter is deprecated and throws from v.3.0.0 on.\n' +
911
+ 'Please check the doku (https://github.com/NodeRedis/node_redis) and explictly use flush.'
911
912
) ;
912
913
}
913
914
0 commit comments