Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between client.end() and client.quit() in redis?

Tags:

redis

Right now I am using redis in node js app. While go through the redis node js code, two functions end() and quit() are used. I am confused with that thing

like image 450
Navin prasad Avatar asked Feb 25 '17 09:02

Navin prasad


People also ask

What is Redis quit?

Redis QUIT command asks the server to close the connection. The connection is closed as soon as all pending replies have been written to the client.

How do I close Redis client connection?

Due to the single-threaded nature of Redis, it is not possible to kill a client connection while it is executing a command. From the client point of view, the connection can never be closed in the middle of the execution of a command.

What is client connection in Redis?

Redis accepts clients connections on the configured TCP port and on the Unix socket if enabled. When a new client connection is accepted the following operations are performed: The client socket is put in the non-blocking state since Redis uses multiplexing and non-blocking I/O.

How does Redis handle multiple connections?

Redis can handle many connections, and by default, Redis has a maximum number of client connections set at 10,000 connections. You can set the maximum number of client connections you want the Redis server to accept by altering the maxclient from within the redis. conf file.


1 Answers

client.end() Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.

client.quit() This sends the quit command to the redis server and ends cleanly right after all running commands were properly handled. If this is called while reconnecting (and therefor no connection to the redis server exists) it is going to end the connection right away instead of resulting in further reconnections! All offline commands are going to be flushed with an error in that case.

like image 162
Shubham Batra Avatar answered Oct 13 '22 13:10

Shubham Batra