mirror of
https://github.com/predis/predis.git
synced 2026-08-31 12:43:31 +00:00
ZUNION and ZINTER have been changed to ZUNIONSTORE and ZINTERSTORE for consistency (see Redis commit 5d373da).
This commit is contained in:
@@ -8,7 +8,7 @@ v0.6.0
|
||||
|
||||
* New commands added to the Redis 2.0 profile since Predis 0.5.1:
|
||||
- Strings: SETEX, APPEND, SUBSTR
|
||||
- ZSets : ZCOUNT, ZRANK, ZUNION, ZINTER, ZREMBYRANK, ZREVRANK
|
||||
- ZSets : ZCOUNT, ZRANK, ZUNIONSTORE, ZINTERSTORE, ZREMBYRANK, ZREVRANK
|
||||
- Hashes : HSET, HSETNX, HMSET, HINCRBY, HGET, HMGET, HDEL, HEXISTS,
|
||||
HLEN, HKEYS, HVALS, HGETALL
|
||||
- PubSub : PUBLISH, SUBSCRIBE, UNSUBSCRIBE
|
||||
|
||||
+8
-8
@@ -1469,10 +1469,10 @@ class RedisServer_vNext extends RedisServer_v1_2 {
|
||||
'popLastBlocking' => '\Predis\Commands\ListPopLastBlocking',
|
||||
|
||||
/* commands operating on sorted sets */
|
||||
'zunion' => '\Predis\Commands\ZSetUnion',
|
||||
'zsetUnion' => '\Predis\Commands\ZSetUnion',
|
||||
'zinter' => '\Predis\Commands\ZSetIntersection',
|
||||
'zsetIntersection' => '\Predis\Commands\ZSetIntersection',
|
||||
'zunionstore' => '\Predis\Commands\ZSetUnionStore',
|
||||
'zsetUnionStore' => '\Predis\Commands\ZSetUnionStore',
|
||||
'zinterstore' => '\Predis\Commands\ZSetIntersectionStore',
|
||||
'zsetIntersectionStore' => '\Predis\Commands\ZSetIntersectionStore',
|
||||
'zcount' => '\Predis\Commands\ZSetCount',
|
||||
'zsetCount' => '\Predis\Commands\ZSetCount',
|
||||
'zrank' => '\Predis\Commands\ZSetRank',
|
||||
@@ -2079,8 +2079,8 @@ class ZSetRemove extends \Predis\MultiBulkCommand {
|
||||
public function parseResponse($data) { return (bool) $data; }
|
||||
}
|
||||
|
||||
class ZSetUnion extends \Predis\MultiBulkCommand {
|
||||
public function getCommandId() { return 'ZUNION'; }
|
||||
class ZSetUnionStore extends \Predis\MultiBulkCommand {
|
||||
public function getCommandId() { return 'ZUNIONSTORE'; }
|
||||
public function filterArguments(Array $arguments) {
|
||||
$options = array();
|
||||
$argc = count($arguments);
|
||||
@@ -2106,8 +2106,8 @@ class ZSetUnion extends \Predis\MultiBulkCommand {
|
||||
}
|
||||
}
|
||||
|
||||
class ZSetIntersection extends \Predis\Commands\ZSetUnion {
|
||||
public function getCommandId() { return 'ZINTER'; }
|
||||
class ZSetIntersectionStore extends \Predis\Commands\ZSetUnionStore {
|
||||
public function getCommandId() { return 'ZINTERSTORE'; }
|
||||
}
|
||||
|
||||
class ZSetRange extends \Predis\MultiBulkCommand {
|
||||
|
||||
+20
-20
@@ -1188,34 +1188,34 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
});
|
||||
}
|
||||
|
||||
function testZsetUnion() {
|
||||
function testZsetUnionStore() {
|
||||
$zsetA = RC::zsetAddAndReturn($this->redis, 'zseta', array('a' => 1, 'b' => 2, 'c' => 3));
|
||||
$zsetB = RC::zsetAddAndReturn($this->redis, 'zsetb', array('b' => 1, 'c' => 2, 'd' => 3));
|
||||
|
||||
// basic ZUNION
|
||||
$this->assertEquals(4, $this->redis->zunion('zsetc', 2, 'zseta', 'zsetb'));
|
||||
// basic ZUNIONSTORE
|
||||
$this->assertEquals(4, $this->redis->zunionstore('zsetc', 2, 'zseta', 'zsetb'));
|
||||
$this->assertEquals(
|
||||
array(array('a', 1), array('b', 3), array('d', 3), array('c', 5)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
);
|
||||
|
||||
$this->assertEquals(3, $this->redis->zunion('zsetc', 2, 'zseta', 'zsetbNull'));
|
||||
$this->assertEquals(3, $this->redis->zunionstore('zsetc', 2, 'zseta', 'zsetbNull'));
|
||||
$this->assertEquals(
|
||||
array(array('a', 1), array('b', 2), array('c', 3)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
);
|
||||
|
||||
$this->assertEquals(3, $this->redis->zunion('zsetc', 2, 'zsetaNull', 'zsetb'));
|
||||
$this->assertEquals(3, $this->redis->zunionstore('zsetc', 2, 'zsetaNull', 'zsetb'));
|
||||
$this->assertEquals(
|
||||
array(array('b', 1), array('c', 2), array('d', 3)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
);
|
||||
|
||||
$this->assertEquals(0, $this->redis->zunion('zsetc', 2, 'zsetaNull', 'zsetbNull'));
|
||||
$this->assertEquals(0, $this->redis->zunionstore('zsetc', 2, 'zsetaNull', 'zsetbNull'));
|
||||
|
||||
// with WEIGHTS
|
||||
$options = array('weights' => array(2, 3));
|
||||
$this->assertEquals(4, $this->redis->zunion('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(4, $this->redis->zunionstore('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(
|
||||
array(array('a', 2), array('b', 7), array('d', 9), array('c', 12)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
@@ -1223,7 +1223,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
|
||||
// with AGGREGATE (min)
|
||||
$options = array('aggregate' => 'min');
|
||||
$this->assertEquals(4, $this->redis->zunion('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(4, $this->redis->zunionstore('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(
|
||||
array(array('a', 1), array('b', 1), array('c', 2), array('d', 3)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
@@ -1231,7 +1231,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
|
||||
// with AGGREGATE (max)
|
||||
$options = array('aggregate' => 'max');
|
||||
$this->assertEquals(4, $this->redis->zunion('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(4, $this->redis->zunionstore('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(
|
||||
array(array('a', 1), array('b', 2), array('c', 3), array('d', 3)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
@@ -1239,28 +1239,28 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
|
||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||
$test->redis->set('zsetFake', 'fake');
|
||||
$test->redis->zunion('zsetc', 2, 'zseta', 'zsetFake');
|
||||
$test->redis->zunionstore('zsetc', 2, 'zseta', 'zsetFake');
|
||||
});
|
||||
}
|
||||
|
||||
function testZsetIntersection() {
|
||||
function testZsetIntersectionStore() {
|
||||
$zsetA = RC::zsetAddAndReturn($this->redis, 'zseta', array('a' => 1, 'b' => 2, 'c' => 3));
|
||||
$zsetB = RC::zsetAddAndReturn($this->redis, 'zsetb', array('b' => 1, 'c' => 2, 'd' => 3));
|
||||
|
||||
// basic ZINTER
|
||||
$this->assertEquals(2, $this->redis->zinter('zsetc', 2, 'zseta', 'zsetb'));
|
||||
// basic ZINTERSTORE
|
||||
$this->assertEquals(2, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetb'));
|
||||
$this->assertEquals(
|
||||
array(array('b', 3), array('c', 5)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
);
|
||||
|
||||
$this->assertEquals(0, $this->redis->zinter('zsetc', 2, 'zseta', 'zsetbNull'));
|
||||
$this->assertEquals(0, $this->redis->zinter('zsetc', 2, 'zsetaNull', 'zsetb'));
|
||||
$this->assertEquals(0, $this->redis->zinter('zsetc', 2, 'zsetaNull', 'zsetbNull'));
|
||||
$this->assertEquals(0, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetbNull'));
|
||||
$this->assertEquals(0, $this->redis->zinterstore('zsetc', 2, 'zsetaNull', 'zsetb'));
|
||||
$this->assertEquals(0, $this->redis->zinterstore('zsetc', 2, 'zsetaNull', 'zsetbNull'));
|
||||
|
||||
// with WEIGHTS
|
||||
$options = array('weights' => array(2, 3));
|
||||
$this->assertEquals(2, $this->redis->zinter('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(2, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(
|
||||
array(array('b', 7), array('c', 12)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
@@ -1268,7 +1268,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
|
||||
// with AGGREGATE (min)
|
||||
$options = array('aggregate' => 'min');
|
||||
$this->assertEquals(2, $this->redis->zinter('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(2, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(
|
||||
array(array('b', 1), array('c', 2)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
@@ -1276,7 +1276,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
|
||||
// with AGGREGATE (max)
|
||||
$options = array('aggregate' => 'max');
|
||||
$this->assertEquals(2, $this->redis->zinter('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(2, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetb', $options));
|
||||
$this->assertEquals(
|
||||
array(array('b', 2), array('c', 3)),
|
||||
$this->redis->zrange('zsetc', 0, -1, 'withscores')
|
||||
@@ -1284,7 +1284,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
|
||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||
$test->redis->set('zsetFake', 'fake');
|
||||
$test->redis->zinter('zsetc', 2, 'zseta', 'zsetFake');
|
||||
$test->redis->zinterstore('zsetc', 2, 'zseta', 'zsetFake');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user