@@ -83,28 +83,6 @@ public static function createConnection($servers, array $options = array())
83
83
$ client = new \Memcached ($ options ['persistent_id ' ]);
84
84
$ username = $ options ['username ' ];
85
85
$ password = $ options ['password ' ];
86
- unset($ options ['persistent_id ' ], $ options ['username ' ], $ options ['password ' ]);
87
- $ options = array_change_key_case ($ options , CASE_UPPER );
88
-
89
- // set client's options
90
- $ client ->setOption (\Memcached::OPT_BINARY_PROTOCOL , true );
91
- $ client ->setOption (\Memcached::OPT_NO_BLOCK , true );
92
- if (!array_key_exists ('LIBKETAMA_COMPATIBLE ' , $ options ) && !array_key_exists (\Memcached::OPT_LIBKETAMA_COMPATIBLE , $ options )) {
93
- $ client ->setOption (\Memcached::OPT_LIBKETAMA_COMPATIBLE , true );
94
- }
95
- foreach ($ options as $ name => $ value ) {
96
- if (is_int ($ name )) {
97
- continue ;
98
- }
99
- if ('HASH ' === $ name || 'SERIALIZER ' === $ name || 'DISTRIBUTION ' === $ name ) {
100
- $ value = constant ('Memcached:: ' .$ name .'_ ' .strtoupper ($ value ));
101
- }
102
- $ opt = constant ('Memcached::OPT_ ' .$ name );
103
-
104
- unset($ options [$ name ]);
105
- $ options [$ opt ] = $ value ;
106
- }
107
- $ client ->setOptions ($ options );
108
86
109
87
// parse any DSN in $servers
110
88
foreach ($ servers as $ i => $ dsn ) {
@@ -139,11 +117,34 @@ public static function createConnection($servers, array $options = array())
139
117
if (isset ($ params ['query ' ])) {
140
118
parse_str ($ params ['query ' ], $ query );
141
119
$ params += $ query ;
120
+ $ options += $ query ;
142
121
}
143
122
144
123
$ servers [$ i ] = array ($ params ['host ' ], $ params ['port ' ], $ params ['weight ' ]);
145
124
}
146
125
126
+ // set client's options
127
+ unset($ options ['persistent_id ' ], $ options ['username ' ], $ options ['password ' ], $ options ['weight ' ]);
128
+ $ options = array_change_key_case ($ options , CASE_UPPER );
129
+ $ client ->setOption (\Memcached::OPT_BINARY_PROTOCOL , true );
130
+ $ client ->setOption (\Memcached::OPT_NO_BLOCK , true );
131
+ if (!array_key_exists ('LIBKETAMA_COMPATIBLE ' , $ options ) && !array_key_exists (\Memcached::OPT_LIBKETAMA_COMPATIBLE , $ options )) {
132
+ $ client ->setOption (\Memcached::OPT_LIBKETAMA_COMPATIBLE , true );
133
+ }
134
+ foreach ($ options as $ name => $ value ) {
135
+ if (is_int ($ name )) {
136
+ continue ;
137
+ }
138
+ if ('HASH ' === $ name || 'SERIALIZER ' === $ name || 'DISTRIBUTION ' === $ name ) {
139
+ $ value = constant ('Memcached:: ' .$ name .'_ ' .strtoupper ($ value ));
140
+ }
141
+ $ opt = constant ('Memcached::OPT_ ' .$ name );
142
+
143
+ unset($ options [$ name ]);
144
+ $ options [$ opt ] = $ value ;
145
+ }
146
+ $ client ->setOptions ($ options );
147
+
147
148
// set client's servers, taking care of persistent connections
148
149
if (!$ client ->isPristine ()) {
149
150
$ oldServers = array ();
0 commit comments