Skip to content

Commit fe3fb43

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 cf5ea8e commit fe3fb43

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
@@ -25,11 +25,13 @@ public function __construct($prefix = '') {
2525
self::$cache = new \Memcached();
2626

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

3436
// Enable compression
3537
\Memcached::OPT_COMPRESSION => true,
@@ -39,6 +41,9 @@ public function __construct($prefix = '') {
3941

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

0 commit comments

Comments
 (0)