Skip to content

Commit a929e1c

Browse files
Merge pull request #62702 from nextcloud/backport/62670/stable34
[stable34] fix(MemcachedFactory): Enable TCP_NODELAY and adjust default timeouts to be reasonable
2 parents 0418a83 + cef1517 commit a929e1c

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

3131
$defaultOptions = [
32-
\Memcached::OPT_CONNECT_TIMEOUT => 50,
33-
\Memcached::OPT_RETRY_TIMEOUT => 50,
34-
\Memcached::OPT_SEND_TIMEOUT => 50,
35-
\Memcached::OPT_RECV_TIMEOUT => 50,
36-
\Memcached::OPT_POLL_TIMEOUT => 50,
32+
// Set connect and polling timeouts to 500 milliseconds
33+
\Memcached::OPT_CONNECT_TIMEOUT => 500,
34+
\Memcached::OPT_POLL_TIMEOUT => 500,
35+
36+
// Set send and receive timeouts to 500000 microseconds
37+
\Memcached::OPT_SEND_TIMEOUT => 500000,
38+
\Memcached::OPT_RECV_TIMEOUT => 500000,
3739

3840
// Enable compression
3941
\Memcached::OPT_COMPRESSION => true,
@@ -43,6 +45,9 @@ public function __construct($prefix = '') {
4345

4446
// Enable Binary Protocol
4547
\Memcached::OPT_BINARY_PROTOCOL => true,
48+
49+
// Disable Nagle algorithm to speed up connection
50+
\Memcached::OPT_TCP_NODELAY => true,
4651
];
4752
/**
4853
* By default enable igbinary serializer if available

0 commit comments

Comments
 (0)