@@ -32,13 +32,6 @@ class MemcachedAdapter extends AbstractAdapter
32
32
33
33
protected $ maxIdLength = 250 ;
34
34
35
- private const DEFAULT_CLIENT_OPTIONS = [
36
- 'persistent_id ' => null ,
37
- 'username ' => null ,
38
- 'password ' => null ,
39
- \Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP ,
40
- ];
41
-
42
35
private $ marshaller ;
43
36
private $ client ;
44
37
private $ lazyClient ;
@@ -106,10 +99,9 @@ public static function createConnection($servers, array $options = [])
106
99
}
107
100
set_error_handler (function ($ type , $ msg , $ file , $ line ) { throw new \ErrorException ($ msg , 0 , $ type , $ file , $ line ); });
108
101
try {
109
- $ options += static ::DEFAULT_CLIENT_OPTIONS ;
110
- $ client = new \Memcached ($ options ['persistent_id ' ]);
111
- $ username = $ options ['username ' ];
112
- $ password = $ options ['password ' ];
102
+ $ client = new \Memcached ($ options ['persistent_id ' ] ?? null );
103
+ $ username = $ options ['username ' ] ?? null ;
104
+ $ password = $ options ['password ' ] ?? null ;
113
105
114
106
// parse any DSN in $servers
115
107
foreach ($ servers as $ i => $ dsn ) {
@@ -180,6 +172,7 @@ public static function createConnection($servers, array $options = [])
180
172
// set client's options
181
173
unset($ options ['persistent_id ' ], $ options ['username ' ], $ options ['password ' ], $ options ['weight ' ], $ options ['lazy ' ]);
182
174
$ options = array_change_key_case ($ options , \CASE_UPPER );
175
+
183
176
$ client ->setOption (\Memcached::OPT_BINARY_PROTOCOL , true );
184
177
$ client ->setOption (\Memcached::OPT_NO_BLOCK , true );
185
178
$ client ->setOption (\Memcached::OPT_TCP_NODELAY , true );
@@ -199,7 +192,7 @@ public static function createConnection($servers, array $options = [])
199
192
$ options [\constant ('Memcached::OPT_ ' .$ name )] = $ value ;
200
193
}
201
194
}
202
- $ client ->setOptions ($ options );
195
+ $ client ->setOptions ($ options + [\Memcached:: OPT_SERIALIZER => \Memcached:: SERIALIZER_PHP ] );
203
196
204
197
// set client's servers, taking care of persistent connections
205
198
if (!$ client ->isPristine ()) {
0 commit comments