You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,7 +147,7 @@ So please attach the error listener to node_redis.
147
147
148
148
`client` will emit `end` when an established Redis server connection has closed.
149
149
150
-
### "drain"
150
+
### "drain" (deprecated)
151
151
152
152
`client` will emit `drain` when the TCP connection to the Redis server has been buffering, but is now
153
153
writable. This event can be used to stream commands in to Redis and adapt to backpressure.
@@ -162,20 +162,21 @@ If false is returned the stream had to buffer.
162
162
163
163
`client` will emit `warning` when password was set but none is needed and if a deprecated option / function / similar is used.
164
164
165
-
### "idle"
165
+
### "idle" (deprecated)
166
166
167
167
`client` will emit `idle` when there are no outstanding commands that are awaiting a response.
168
168
169
169
## redis.createClient()
170
170
If you have `redis-server` running on the same computer as node, then the defaults for
171
171
port and host are probably fine and you don't need to supply any arguments. `createClient()` returns a `RedisClient` object.
172
172
173
+
If the redis server runs on the same machine as the client consider using unix sockets if possible to increase throughput.
174
+
173
175
### overloading
174
-
*`redis.createClient()`
175
-
*`redis.createClient(options)`
176
-
*`redis.createClient(unix_socket, options)`
177
-
*`redis.createClient(redis_url, options)`
178
-
*`redis.createClient(port, host, options)`
176
+
*`redis.createClient([options])`
177
+
*`redis.createClient(unix_socket[, options])`
178
+
*`redis.createClient(redis_url[, options])`
179
+
*`redis.createClient(port[, host][, options])`
179
180
180
181
#### `options` is an object with the following possible properties:
181
182
*`host`: *127.0.0.1*; The host to connect to
@@ -204,10 +205,10 @@ This delay normally grows infinitely, but setting `retry_max_delay` limits it to
204
205
*`connect_timeout`: *3600000*; Setting `connect_timeout` limits total time for client to connect and reconnect.
205
206
The value is provided in milliseconds and is counted from the moment on a new client is created / a connection is lost. The last retry is going to happen exactly at the timeout time.
206
207
Default is to try connecting until the default system socket timeout has been exceeded and to try reconnecting until 1h passed.
207
-
*`max_attempts`: *0*; By default client will try reconnecting until connected. Setting `max_attempts`
208
+
*`max_attempts`: *0*; (Deprecated, please use `retry_strategy` instead) By default client will try reconnecting until connected. Setting `max_attempts`
208
209
limits total amount of connection tries. Setting this to 1 will prevent any reconnect tries.
209
210
*`retry_unfulfilled_commands`: *false*; If set to true, all commands that were unfulfulled while the connection is lost will be retried after the connection has reestablished again. Use this with caution, if you use state altering commands (e.g. *incr*). This is especially useful if you use blocking commands.
210
-
*`password`: *null*; If set, client will run redis auth command on connect. Alias `auth_pass`
211
+
*`password`: *null*; If set, client will run redis auth command on connect. Alias `auth_pass` (node_redis < 2.5 have to use auth_pass)
211
212
*`db`: *null*; If set, client will run redis select command on connect. This is [not recommended](https://groups.google.com/forum/#!topic/redis-db/vS5wX8X4Cjg).
212
213
*`family`: *IPv4*; You can force using IPv6 if you set the family to 'IPv6'. See Node.js [net](https://nodejs.org/api/net.html) or [dns](https://nodejs.org/api/dns.html) modules how to use the family type.
213
214
*`disable_resubscribing`: *false*; If set to `true`, a client won't resubscribe after disconnecting
Copy file name to clipboardExpand all lines: index.js
+67-24Lines changed: 67 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -51,20 +51,32 @@ function RedisClient (options) {
51
51
for(vartls_optioninoptions.tls){// jshint ignore: line
52
52
cnx_options[tls_option]=options.tls[tls_option];
53
53
}
54
+
// Warn on misusing deprecated functions
55
+
if(typeofoptions.retry_strategy==='function'){
56
+
if('max_attempts'inoptions){
57
+
self.warn('WARNING: You activated the retry_strategy and max_attempts at the same time. This is not possible and max_attempts will be ignored.');
58
+
// Do not print deprecation warnings twice
59
+
deleteoptions.max_attempts;
60
+
}
61
+
if('retry_max_delay'inoptions){
62
+
self.warn('WARNING: You activated the retry_strategy and retry_max_delay at the same time. This is not possible and retry_max_delay will be ignored.');
63
+
// Do not print deprecation warnings twice
64
+
deleteoptions.retry_max_delay;
65
+
}
66
+
}
67
+
54
68
this.connection_options=cnx_options;
55
-
this.connection_id=++connection_id;
69
+
this.connection_id=RedisClient.connection_id++;
56
70
this.connected=false;
57
71
this.ready=false;
58
72
if(options.socket_nodelay===undefined){
59
73
options.socket_nodelay=true;
60
74
}elseif(!options.socket_nodelay){// Only warn users with this set to false
61
-
process.nextTick(function(){
62
-
self.warn(
63
-
'socket_nodelay is deprecated and will be removed in v.3.0.0.\n'+
64
-
'Setting socket_nodelay to false likely results in a reduced throughput. Please use .batch to buffer commands and use pipelining.\n'+
65
-
'If you are sure you rely on the NAGLE-algorithm you can activate it by calling client.stream.setNoDelay(false) instead.'
66
-
);
67
-
});
75
+
self.warn(
76
+
'socket_nodelay is deprecated and will be removed in v.3.0.0.\n'+
77
+
'Setting socket_nodelay to false likely results in a reduced throughput. Please use .batch for pipelining instead.\n'+
78
+
'If you are sure you rely on the NAGLE-algorithm you can activate it by calling client.stream.setNoDelay(false) instead.'
79
+
);
68
80
}
69
81
if(options.socket_keepalive===undefined){
70
82
options.socket_keepalive=true;
@@ -76,9 +88,7 @@ function RedisClient (options) {
76
88
options.detect_buffers=!!options.detect_buffers;
77
89
// Override the detect_buffers setting if return_buffers is active and print a warning
0 commit comments