mirror of
https://github.com/predis/predis.git
synced 2026-09-20 15:26:46 +00:00
Fix SINTERSTORE and SUNIONSTORE to accept an array for the list of source keys.
This commit is contained in:
@@ -16,7 +16,9 @@ v0.6.6 (2011-xx-xx)
|
||||
* ZUNIONSTORE and ZINTERSTORE can accept an array to specify a list of the
|
||||
source keys to be used to populate the destination key.
|
||||
|
||||
* MGET, SINTER and SUNION can accept an array to specify the list of keys.
|
||||
* MGET, SINTER and SUNION can accept an array to specify the list of keys.
|
||||
SINTERSTORE and SUNIONSTORE can also accept an array to specify the list
|
||||
of source keys.
|
||||
|
||||
* SUBSCRIBE and PSUBSCRIBE can accept a list of channels for subscription.
|
||||
|
||||
|
||||
@@ -2687,6 +2687,12 @@ class SetIntersection extends \Predis\MultiBulkCommand {
|
||||
|
||||
class SetIntersectionStore extends \Predis\MultiBulkCommand {
|
||||
public function getCommandId() { return 'SINTERSTORE'; }
|
||||
public function filterArguments(Array $arguments) {
|
||||
if (count($arguments) === 2 && is_array($arguments[1])) {
|
||||
return array_merge(array($arguments[0]), $arguments[1]);
|
||||
}
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
|
||||
class SetUnion extends SetIntersection {
|
||||
@@ -2695,6 +2701,12 @@ class SetUnion extends SetIntersection {
|
||||
|
||||
class SetUnionStore extends \Predis\MultiBulkCommand {
|
||||
public function getCommandId() { return 'SUNIONSTORE'; }
|
||||
public function filterArguments(Array $arguments) {
|
||||
if (count($arguments) === 2 && is_array($arguments[1])) {
|
||||
return array_merge(array($arguments[0]), $arguments[1]);
|
||||
}
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
|
||||
class SetDifference extends \Predis\MultiBulkCommand {
|
||||
|
||||
@@ -1012,6 +1012,9 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$this->redis->set('foo', 'bar');
|
||||
$this->assertEquals(count($setA), $this->redis->sinterstore('foo', 'setA'));
|
||||
|
||||
// accepts an array for the list of source keys
|
||||
$this->assertEquals(4, $this->redis->sinterstore('setC', array('setA', 'setB')));
|
||||
|
||||
// wrong type
|
||||
$this->redis->set('foo', 'bar');
|
||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||
@@ -1075,6 +1078,9 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$this->redis->set('foo', 'bar');
|
||||
$this->assertEquals(count($setA), $this->redis->sunionstore('foo', 'setA'));
|
||||
|
||||
// accepts an array for the list of source keys
|
||||
$this->assertEquals(9, $this->redis->sunionstore('setC', array('setA', 'setB')));
|
||||
|
||||
// wrong type
|
||||
$this->redis->set('foo', 'bar');
|
||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||
|
||||
Reference in New Issue
Block a user