Skip to content

Commit 6a0fe72

Browse files
committed
Only set binary protocol for new connections
1 parent fc0a175 commit 6a0fe72

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/drop-in/object-cache.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ public function __construct(
6565
// https://www.php.net/manual/en/memcached.construct.php
6666
$mc = new Memcached( $persistent_id );
6767

68-
if ( SNAPCACHE_MEMCACHED_USE_BINARY === true
69-
&& $mc->getOption( Memcached::OPT_BINARY_PROTOCOL ) === false ) {
70-
$result = $mc->setOption( Memcached::OPT_BINARY_PROTOCOL, true );
68+
// We can only enable binary protocol for new connections
69+
if ( $mc->isPristine() ) {
70+
$result = $mc->setOptions(
71+
[
72+
Memcached::OPT_BINARY_PROTOCOL => SNAPCACHE_MEMCACHED_USE_BINARY === true,
73+
]
74+
);
7175

7276
if ( $result === false ) {
7377
error_log( 'Failed to enable binary protocol for Memcached' );

0 commit comments

Comments
 (0)