mirror of
https://github.com/predis/predis.git
synced 2026-08-24 11:59:36 +00:00
c4064e5801
List of the commands affected by this change (based on Redis 2.2):
MSET, MGET, DEL, BLPOP, BRPOP, RPOPLPUSH, BRPOPLPUSH, SINTER, SINTERSTORE,
SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, ZINTERSTORE, ZUNIONSTORE.
43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Predis\Commands;
|
|
|
|
class ZSetUnionStore extends Command {
|
|
protected function canBeHashed() {
|
|
$args = $this->getArguments();
|
|
return $this->checkSameHashForKeys(
|
|
array_merge(array($args[0]), array_slice($args, 2, $args[1]))
|
|
);
|
|
}
|
|
public function getId() { return 'ZUNIONSTORE'; }
|
|
public function filterArguments(Array $arguments) {
|
|
$options = array();
|
|
$argc = count($arguments);
|
|
if ($argc > 2 && is_array($arguments[$argc - 1])) {
|
|
$options = $this->prepareOptions(array_pop($arguments));
|
|
}
|
|
if (is_array($arguments[1])) {
|
|
$arguments = array_merge(
|
|
array($arguments[0], count($arguments[1])),
|
|
$arguments[1]
|
|
);
|
|
}
|
|
return array_merge($arguments, $options);
|
|
}
|
|
private function prepareOptions($options) {
|
|
$opts = array_change_key_case($options, CASE_UPPER);
|
|
$finalizedOpts = array();
|
|
if (isset($opts['WEIGHTS']) && is_array($opts['WEIGHTS'])) {
|
|
$finalizedOpts[] = 'WEIGHTS';
|
|
foreach ($opts['WEIGHTS'] as $weight) {
|
|
$finalizedOpts[] = $weight;
|
|
}
|
|
}
|
|
if (isset($opts['AGGREGATE'])) {
|
|
$finalizedOpts[] = 'AGGREGATE';
|
|
$finalizedOpts[] = $opts['AGGREGATE'];
|
|
}
|
|
return $finalizedOpts;
|
|
}
|
|
}
|