bug #28249 [Cache] enable Memcached::OPT_TCP_NODELAY to fix perf of misses (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[Cache] enable Memcached::OPT_TCP_NODELAY to fix perf of misses

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28248
| License       | MIT
| Doc PR        | -

As described in https://github.com/php-memcached-dev/php-memcached/issues/24 and because we enable the binary protocol by default.

Commits
-------

8b59d177db [Cache] enable Memcached::OPT_TCP_NODELAY to fix perf of misses
This commit is contained in:
Nicolas Grekas 2018-08-24 11:47:29 +02:00
commit 8860b6691c
2 changed files with 2 additions and 0 deletions

View File

@ -89,6 +89,7 @@ class MemcachedAdapterTest extends AdapterTestCase
$this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION));
$this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL));
$this->assertSame(1, $client->getOption(\Memcached::OPT_TCP_NODELAY));
$this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE));
}

View File

@ -134,6 +134,7 @@ trait MemcachedTrait
$options = array_change_key_case($options, CASE_UPPER);
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
if (!array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
$client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
}