Skip to content

Commit a956296

Browse files
committed
fix(MemcachedFactory): Enable TCP_NODELAY and adjust default timeouts to be reasonable
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
1 parent a019b45 commit a956296

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

lib/private/Memcache/Memcached.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ public function __construct($prefix = '') {
2626
self::$cache = new \Memcached();
2727

2828
$defaultOptions = [
29-
\Memcached::OPT_CONNECT_TIMEOUT => 50,
30-
\Memcached::OPT_RETRY_TIMEOUT => 50,
31-
\Memcached::OPT_SEND_TIMEOUT => 50,
32-
\Memcached::OPT_RECV_TIMEOUT => 50,
33-
\Memcached::OPT_POLL_TIMEOUT => 50,
29+
// Set connect and polling timeouts to 500 milliseconds
30+
\Memcached::OPT_CONNECT_TIMEOUT => 500,
31+
\Memcached::OPT_POLL_TIMEOUT => 500,
32+
33+
// Set send and receive timeouts to 500000 microseconds
34+
\Memcached::OPT_SEND_TIMEOUT => 500000,
35+
\Memcached::OPT_RECV_TIMEOUT => 500000,
3436

3537
// Enable compression
3638
\Memcached::OPT_COMPRESSION => true,
@@ -40,6 +42,9 @@ public function __construct($prefix = '') {
4042

4143
// Enable Binary Protocol
4244
\Memcached::OPT_BINARY_PROTOCOL => true,
45+
46+
// Disable Nagle algorithm to speed up connection
47+
\Memcached::OPT_TCP_NODELAY => true,
4348
];
4449
/**
4550
* By default enable igbinary serializer if available

0 commit comments

Comments
 (0)