@@ -246,12 +246,13 @@ NOTE: Your call to `client.auth()` should not be inside the ready handler. If
246246you are doing this wrong, ` client ` will emit an error that looks
247247something like this ` Error: Ready check failed: ERR operation not permitted ` .
248248
249- ## client.end([ flush] )
249+ ## client.end(flush)
250250
251251Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.
252252If you want to exit cleanly, call ` client.quit() ` to send the ` QUIT ` command after you have handled all replies.
253253
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.
255256
256257This example closes the connection to the Redis server before the replies have been read. You probably don't
257258want to do this:
@@ -260,12 +261,15 @@ want to do this:
260261var redis = require (" redis" ),
261262 client = redis .createClient ();
262263
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)
267267 console .log (err);
268268});
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+ });
269273```
270274
271275` client.end() ` without the flush parameter should not be used in production!
0 commit comments