Skip to content

Commit 52f9873

Browse files
author
Ruben Bridgewater
committed
Deprecate stuff
1 parent e83230f commit 52f9873

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

index.js

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,14 @@ function RedisClient (options) {
5555
this.connection_id = ++connection_id;
5656
this.connected = false;
5757
this.ready = false;
58-
this.connections = 0;
5958
if (options.socket_nodelay === undefined) {
6059
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+
);
6166
}
6267
if (options.socket_keepalive === undefined) {
6368
options.socket_keepalive = true;
@@ -730,34 +735,31 @@ RedisClient.prototype.send_command = function (command, args, callback) {
730735
this.writeDefault = this.writeBuffers;
731736
}
732737
}
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) {
735743
console.warn(
736744
'node_redis: Deprecated: The %s command contains a "null" argument.\n' +
737745
'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()
739747
);
740748
args[i] = 'null'; // Backwards compatible :/
741749
} 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+
}
760755
}
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 :/
761763
}
762764
}
763765

@@ -903,11 +905,10 @@ RedisClient.prototype.end = function (flush) {
903905
// Flush queue if wanted
904906
if (flush) {
905907
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) {
907909
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.'
911912
);
912913
}
913914

0 commit comments

Comments
 (0)