Skip to content

Commit b9219a0

Browse files
committed
Merge branch 'set-keepalive' of https://github.com/Clever/node_redis into Clever-set-keepalive
2 parents f7134a6 + d313aa5 commit b9219a0

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ every command on a client.
192192
* `socket_nodelay`: defaults to `true`. Whether to call setNoDelay() on the TCP stream, which disables the
193193
Nagle algorithm on the underlying socket. Setting this option to `false` can result in additional throughput at the
194194
cost of more latency. Most applications will want this set to `true`.
195+
* `socket_keepalive` defaults to `false`. Whether the keep-alive functionality is enabled on the underlying socket.
195196
* `no_ready_check`: defaults to `false`. When a connection is established to the Redis server, the server might still
196197
be loading the database from disk. While loading, the server not respond to any commands. To work around this,
197198
`node_redis` has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ function RedisClient(stream, options) {
4343
if (this.options.socket_nodelay === undefined) {
4444
this.options.socket_nodelay = true;
4545
}
46+
if (this.options.socket_keepalive === undefined) {
47+
this.options.socket_keepalive = false;
48+
}
4649
this.should_buffer = false;
4750
this.command_queue_high_water = this.options.command_queue_high_water || 1000;
4851
this.command_queue_low_water = this.options.command_queue_low_water || 0;
@@ -253,6 +256,7 @@ RedisClient.prototype.on_connect = function () {
253256
if (this.options.socket_nodelay) {
254257
this.stream.setNoDelay();
255258
}
259+
this.stream.setKeepAlive(this.options.socket_keepalive);
256260
this.stream.setTimeout(0);
257261

258262
this.init_parser();

0 commit comments

Comments
 (0)