You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Merge branch 'set-keepalive' of https://github.com/Clever/node_redis into Clever-set-keepalive
This commit is contained in:
@@ -192,6 +192,7 @@ every command on a client.
|
|||||||
* `socket_nodelay`: defaults to `true`. Whether to call setNoDelay() on the TCP stream, which disables the
|
* `socket_nodelay`: defaults to `true`. Whether to call setNoDelay() on the TCP stream, which disables the
|
||||||
Nagle algorithm on the underlying socket. Setting this option to `false` can result in additional throughput at the
|
Nagle algorithm on the underlying socket. Setting this option to `false` can result in additional throughput at the
|
||||||
cost of more latency. Most applications will want this set to `true`.
|
cost of more latency. Most applications will want this set to `true`.
|
||||||
|
* `socket_keepalive` defaults to `false`. Whether the keep-alive functionality is enabled on the underlying socket.
|
||||||
* `no_ready_check`: defaults to `false`. When a connection is established to the Redis server, the server might still
|
* `no_ready_check`: defaults to `false`. When a connection is established to the Redis server, the server might still
|
||||||
be loading the database from disk. While loading, the server not respond to any commands. To work around this,
|
be loading the database from disk. While loading, the server not respond to any commands. To work around this,
|
||||||
`node_redis` has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command
|
`node_redis` has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command
|
||||||
|
4
index.js
4
index.js
@@ -43,6 +43,9 @@ function RedisClient(stream, options) {
|
|||||||
if (this.options.socket_nodelay === undefined) {
|
if (this.options.socket_nodelay === undefined) {
|
||||||
this.options.socket_nodelay = true;
|
this.options.socket_nodelay = true;
|
||||||
}
|
}
|
||||||
|
if (this.options.socket_keepalive === undefined) {
|
||||||
|
this.options.socket_keepalive = false;
|
||||||
|
}
|
||||||
this.should_buffer = false;
|
this.should_buffer = false;
|
||||||
this.command_queue_high_water = this.options.command_queue_high_water || 1000;
|
this.command_queue_high_water = this.options.command_queue_high_water || 1000;
|
||||||
this.command_queue_low_water = this.options.command_queue_low_water || 0;
|
this.command_queue_low_water = this.options.command_queue_low_water || 0;
|
||||||
@@ -253,6 +256,7 @@ RedisClient.prototype.on_connect = function () {
|
|||||||
if (this.options.socket_nodelay) {
|
if (this.options.socket_nodelay) {
|
||||||
this.stream.setNoDelay();
|
this.stream.setNoDelay();
|
||||||
}
|
}
|
||||||
|
this.stream.setKeepAlive(this.options.socket_keepalive);
|
||||||
this.stream.setTimeout(0);
|
this.stream.setTimeout(0);
|
||||||
|
|
||||||
this.init_parser();
|
this.init_parser();
|
||||||
|
Reference in New Issue
Block a user