diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Memcache/Memcached.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/private/Memcache/Memcached.php b/lib/private/Memcache/Memcached.php index a30f9da7ed7..63ac73e9b9d 100644 --- a/lib/private/Memcache/Memcached.php +++ b/lib/private/Memcache/Memcached.php @@ -26,6 +26,7 @@ namespace OC\Memcache; +use OC\HintException; use OCP\IMemcache; class Memcached extends Cache implements IMemcache { @@ -52,6 +53,35 @@ class Memcached extends Cache implements IMemcache { } } self::$cache->addServers($servers); + + $defaultOptions = [ + \Memcached::OPT_CONNECT_TIMEOUT => 50, + \Memcached::OPT_RETRY_TIMEOUT => 50, + \Memcached::OPT_SEND_TIMEOUT => 50, + \Memcached::OPT_RECV_TIMEOUT => 50, + \Memcached::OPT_POLL_TIMEOUT => 50, + + // Enable compression + \Memcached::OPT_COMPRESSION => true, + + // Turn on consistent hashing + \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, + + // Enable Binary Protocol + \Memcached::OPT_BINARY_PROTOCOL => true, + ]; + // by default enable igbinary serializer if available + if (\Memcached::HAVE_IGBINARY) { + $defaultOptions[\Memcached::OPT_SERIALIZER] = + \Memcached::SERIALIZER_IGBINARY; + } + $options = \OC::$server->getConfig()->getSystemValue('memcached_options', []); + if (is_array($options)) { + $options = $options + $defaultOptions; + self::$cache->setOptions($options); + } else { + throw new HintException("Expected 'memcached_options' config to be an array, got $options"); + } } } |