@@ -246,12 +246,13 @@ NOTE: Your call to `client.auth()` should not be inside the ready handler. If
246
246
you are doing this wrong, ` client ` will emit an error that looks
247
247
something like this ` Error: Ready check failed: ERR operation not permitted ` .
248
248
249
- ## client.end([ flush] )
249
+ ## client.end(flush)
250
250
251
251
Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.
252
252
If you want to exit cleanly, call ` client.quit() ` to send the ` QUIT ` command after you have handled all replies.
253
253
254
- If flush is set to true, all still running commands will be rejected instead of ignored after using ` .end ` .
254
+ You should set flush to true, if you are not absolutly sure you do not care about any other commands.
255
+ If you set flush to false all still running commands will silently fail.
255
256
256
257
This example closes the connection to the Redis server before the replies have been read. You probably don't
257
258
want to do this:
@@ -260,12 +261,15 @@ want to do this:
260
261
var redis = require (" redis" ),
261
262
client = redis .createClient ();
262
263
263
- client .set (" foo_rand000000000000" , " some fantastic value" );
264
- client .end (); // No further commands will be processed
265
- client .get (" foo_rand000000000000" , function (err , reply ) {
266
- // This won't be called anymore, since flush has not been set to true!
264
+ client .set (" foo_rand000000000000" , " some fantastic value" , function (err , reply ) {
265
+ // This will either result in an error (flush parameter is set to true)
266
+ // or will silently fail and this callback will not be called at all (flush set to false)
267
267
console .log (err);
268
268
});
269
+ client .end (true ); // No further commands will be processed
270
+ client .get (" foo_rand000000000000" , function (err , reply ) {
271
+ console .log (err); // => 'The connection has already been closed.'
272
+ });
269
273
```
270
274
271
275
` client.end() ` without the flush parameter should not be used in production!
0 commit comments