@@ 169-190 (lines=22) @@ | ||
166 | * @return boolean true on success |
|
167 | * @throws RedisProxyException if number of arguments is wrong |
|
168 | */ |
|
169 | public function mset(...$dictionary) |
|
170 | { |
|
171 | if (is_array($dictionary[0])) { |
|
172 | $result = $this->driver->mset(...$dictionary); |
|
173 | return $this->transformResult($result); |
|
174 | } |
|
175 | ||
176 | $keys = array_values(array_filter($dictionary, function ($key) { |
|
177 | return $key % 2 == 0; |
|
178 | }, ARRAY_FILTER_USE_KEY)); |
|
179 | $values = array_values(array_filter($dictionary, function ($key) { |
|
180 | return $key % 2 == 1; |
|
181 | }, ARRAY_FILTER_USE_KEY)); |
|
182 | ||
183 | if (count($keys) != count($values)) { |
|
184 | throw new RedisProxyException('Wrong number of arguments for mset'); |
|
185 | } |
|
186 | ||
187 | $dictionary = array_combine($keys, $values); |
|
188 | $result = $this->driver->mset($dictionary); |
|
189 | return $this->transformResult($result); |
|
190 | } |
|
191 | ||
192 | /** |
|
193 | * @param string $key |
|
@@ 303-324 (lines=22) @@ | ||
300 | * @return boolean true on success |
|
301 | * @throws RedisProxyException if number of arguments is wrong |
|
302 | */ |
|
303 | public function hmset($key, ...$dictionary) |
|
304 | { |
|
305 | if (is_array($dictionary[0])) { |
|
306 | $result = $this->driver->hmset($key, ...$dictionary); |
|
307 | return $this->transformResult($result); |
|
308 | } |
|
309 | ||
310 | $fields = array_values(array_filter($dictionary, function ($dictionaryKey) { |
|
311 | return $dictionaryKey % 2 == 0; |
|
312 | }, ARRAY_FILTER_USE_KEY)); |
|
313 | $values = array_values(array_filter($dictionary, function ($dictionaryKey) { |
|
314 | return $dictionaryKey % 2 == 1; |
|
315 | }, ARRAY_FILTER_USE_KEY)); |
|
316 | ||
317 | if (count($fields) != count($values)) { |
|
318 | throw new RedisProxyException('Wrong number of arguments for hmset'); |
|
319 | } |
|
320 | ||
321 | $dictionary = array_combine($fields, $values); |
|
322 | $result = $this->driver->hmset($key, $dictionary); |
|
323 | return $this->transformResult($result); |
|
324 | } |
|
325 | ||
326 | /** |
|
327 | * Incrementally iterate hash fields and associated values |