mirror of
https://github.com/predis/predis.git
synced 2026-09-16 05:17:02 +00:00
Merge remote-tracking branch 'github/pr/235' into v1.0
Conflicts: .travis.yml CHANGELOG.md VERSION package.ini src/Client.php
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
[](https://packagist.org/packages/predis/predis)
|
[](https://packagist.org/packages/predis/predis)
|
||||||
[](https://packagist.org/packages/predis/predis)
|
[](https://packagist.org/packages/predis/predis)
|
||||||
[](https://packagist.org/packages/predis/predis)
|
[](https://packagist.org/packages/predis/predis)
|
||||||
[](https://travis-ci.org/nrk/predis)
|
[](https://travis-ci.org/nrk/predis)
|
||||||
[](http://hhvm.h4cc.de/package/predis/predis)
|
[](http://hhvm.h4cc.de/package/predis/predis)
|
||||||
|
|
||||||
Predis is a flexible and feature-complete [Redis](http://redis.io) client library for PHP >= 5.3.
|
Predis is a flexible and feature-complete [Redis](http://redis.io) client library for PHP >= 5.3.
|
||||||
|
|||||||
+6
-1
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.2"
|
"php": ">=5.3.9"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~4.0"
|
"phpunit/phpunit": "~4.0"
|
||||||
@@ -27,5 +27,10 @@
|
|||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {"Predis\\": "src/"}
|
"psr-4": {"Predis\\": "src/"}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.1-dev"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ channel = "pear.nrk.io"
|
|||||||
author = "Daniele Alessandri \"nrk\" <suppakilla@gmail.com>"
|
author = "Daniele Alessandri \"nrk\" <suppakilla@gmail.com>"
|
||||||
|
|
||||||
[require]
|
[require]
|
||||||
php = ">= 5.3.2"
|
php = ">= 5.3.9"
|
||||||
pearinstaller = "1.4.1"
|
pearinstaller = "1.4.1"
|
||||||
|
|
||||||
[roles]
|
[roles]
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ abstract class ClusterStrategy implements StrategyInterface
|
|||||||
'ZLEXCOUNT' => $getKeyFromFirstArgument,
|
'ZLEXCOUNT' => $getKeyFromFirstArgument,
|
||||||
'ZRANGEBYLEX' => $getKeyFromFirstArgument,
|
'ZRANGEBYLEX' => $getKeyFromFirstArgument,
|
||||||
'ZREMRANGEBYLEX' => $getKeyFromFirstArgument,
|
'ZREMRANGEBYLEX' => $getKeyFromFirstArgument,
|
||||||
|
'ZREVRANGEBYLEX' => $getKeyFromFirstArgument,
|
||||||
|
|
||||||
/* commands operating on hashes */
|
/* commands operating on hashes */
|
||||||
'HDEL' => $getKeyFromFirstArgument,
|
'HDEL' => $getKeyFromFirstArgument,
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ class KeyPrefixProcessor implements ProcessorInterface
|
|||||||
'ZLEXCOUNT' => 'self::first',
|
'ZLEXCOUNT' => 'self::first',
|
||||||
'ZRANGEBYLEX' => 'self::first',
|
'ZRANGEBYLEX' => 'self::first',
|
||||||
'ZREMRANGEBYLEX' => 'self::first',
|
'ZREMRANGEBYLEX' => 'self::first',
|
||||||
|
'ZREVRANGEBYLEX' => 'self::first',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Predis package.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Predis\Command;
|
||||||
|
|
||||||
|
class ZSetReverseRangeByLex extends ZSetRangeByLex
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return 'ZREVRANGEBYLEX';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -246,6 +246,7 @@ class RedisVersion280 extends RedisProfile
|
|||||||
'ZLEXCOUNT' => 'Predis\Command\ZSetLexCount',
|
'ZLEXCOUNT' => 'Predis\Command\ZSetLexCount',
|
||||||
'ZRANGEBYLEX' => 'Predis\Command\ZSetRangeByLex',
|
'ZRANGEBYLEX' => 'Predis\Command\ZSetRangeByLex',
|
||||||
'ZREMRANGEBYLEX' => 'Predis\Command\ZSetRemoveRangeByLex',
|
'ZREMRANGEBYLEX' => 'Predis\Command\ZSetRemoveRangeByLex',
|
||||||
|
'ZREVRANGEBYLEX' => 'Predis\Command\ZSetReverseRangeByLex',
|
||||||
|
|
||||||
/* commands operating on hashes */
|
/* commands operating on hashes */
|
||||||
'HSCAN' => 'Predis\Command\HashScan',
|
'HSCAN' => 'Predis\Command\HashScan',
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ class RedisVersion300 extends RedisProfile
|
|||||||
'ZLEXCOUNT' => 'Predis\Command\ZSetLexCount',
|
'ZLEXCOUNT' => 'Predis\Command\ZSetLexCount',
|
||||||
'ZRANGEBYLEX' => 'Predis\Command\ZSetRangeByLex',
|
'ZRANGEBYLEX' => 'Predis\Command\ZSetRangeByLex',
|
||||||
'ZREMRANGEBYLEX' => 'Predis\Command\ZSetRemoveRangeByLex',
|
'ZREMRANGEBYLEX' => 'Predis\Command\ZSetRemoveRangeByLex',
|
||||||
|
'ZREVRANGEBYLEX' => 'Predis\Command\ZSetReverseRangeByLex',
|
||||||
|
|
||||||
/* commands operating on hashes */
|
/* commands operating on hashes */
|
||||||
'HSCAN' => 'Predis\Command\HashScan',
|
'HSCAN' => 'Predis\Command\HashScan',
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ class ReplicationStrategy
|
|||||||
'ZSCAN' => true,
|
'ZSCAN' => true,
|
||||||
'ZLEXCOUNT' => true,
|
'ZLEXCOUNT' => true,
|
||||||
'ZRANGEBYLEX' => true,
|
'ZRANGEBYLEX' => true,
|
||||||
|
'ZREVRANGEBYLEX' => true,
|
||||||
'HGET' => true,
|
'HGET' => true,
|
||||||
'HMGET' => true,
|
'HMGET' => true,
|
||||||
'HEXISTS' => true,
|
'HEXISTS' => true,
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ class PredisStrategyTest extends PredisTestCase
|
|||||||
'ZLEXCOUNT' => 'keys-first',
|
'ZLEXCOUNT' => 'keys-first',
|
||||||
'ZRANGEBYLEX' => 'keys-first',
|
'ZRANGEBYLEX' => 'keys-first',
|
||||||
'ZREMRANGEBYLEX' => 'keys-first',
|
'ZREMRANGEBYLEX' => 'keys-first',
|
||||||
|
'ZREVRANGEBYLEX' => 'keys-first',
|
||||||
|
|
||||||
/* commands operating on hashes */
|
/* commands operating on hashes */
|
||||||
'HDEL' => 'keys-first',
|
'HDEL' => 'keys-first',
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ class RedisStrategyTest extends PredisTestCase
|
|||||||
'ZLEXCOUNT' => 'keys-first',
|
'ZLEXCOUNT' => 'keys-first',
|
||||||
'ZRANGEBYLEX' => 'keys-first',
|
'ZRANGEBYLEX' => 'keys-first',
|
||||||
'ZREMRANGEBYLEX' => 'keys-first',
|
'ZREMRANGEBYLEX' => 'keys-first',
|
||||||
|
'ZREVRANGEBYLEX' => 'keys-first',
|
||||||
|
|
||||||
/* commands operating on hashes */
|
/* commands operating on hashes */
|
||||||
'HDEL' => 'keys-first',
|
'HDEL' => 'keys-first',
|
||||||
|
|||||||
@@ -825,6 +825,10 @@ class KeyPrefixProcessorTest extends PredisTestCase
|
|||||||
array('key', '-', '+'),
|
array('key', '-', '+'),
|
||||||
array('prefix:key', '-', '+'),
|
array('prefix:key', '-', '+'),
|
||||||
),
|
),
|
||||||
|
array('ZREVRANGEBYLEX',
|
||||||
|
array('key', '+', '-', 'LIMIT', '0', '10'),
|
||||||
|
array('prefix:key', '+', '-', 'LIMIT', '0', '10'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,192 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Predis package.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Predis\Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group commands
|
||||||
|
* @group realm-zset
|
||||||
|
*/
|
||||||
|
class ZSetRevRangeByLexTest extends PredisCommandTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function getExpectedCommand()
|
||||||
|
{
|
||||||
|
return 'Predis\Command\ZSetReverseRangeByLex';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function getExpectedId()
|
||||||
|
{
|
||||||
|
return 'ZREVRANGEBYLEX';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group disconnected
|
||||||
|
*/
|
||||||
|
public function testFilterArguments()
|
||||||
|
{
|
||||||
|
$modifiers = array(
|
||||||
|
'limit' => array(0, 100),
|
||||||
|
);
|
||||||
|
|
||||||
|
$arguments = array('zset', '[a', '[z', $modifiers);
|
||||||
|
$expected = array('zset', '[a', '[z', 'LIMIT', 0, 100);
|
||||||
|
|
||||||
|
$command = $this->getCommand();
|
||||||
|
$command->setArguments($arguments);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $command->getArguments());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group disconnected
|
||||||
|
*/
|
||||||
|
public function testFilterArgumentsWithNamedLimit()
|
||||||
|
{
|
||||||
|
$arguments = array('zset', '[a', '[z', array('limit' => array('offset' => 1, 'count' => 2)));
|
||||||
|
$expected = array('zset', '[a', '[z', 'LIMIT', 1, 2);
|
||||||
|
|
||||||
|
$command = $this->getCommand();
|
||||||
|
$command->setArguments($arguments);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $command->getArguments());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group disconnected
|
||||||
|
*/
|
||||||
|
public function testParseResponse()
|
||||||
|
{
|
||||||
|
$raw = array('a', 'b', 'c');
|
||||||
|
$expected = array('a', 'b', 'c');
|
||||||
|
|
||||||
|
$command = $this->getCommand();
|
||||||
|
|
||||||
|
$this->assertSame($expected, $command->parseResponse($raw));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group connected
|
||||||
|
* @requiresRedisVersion >= 2.8.9
|
||||||
|
*/
|
||||||
|
public function testReturnsElementsInWholeRange()
|
||||||
|
{
|
||||||
|
$redis = $this->getClient();
|
||||||
|
|
||||||
|
$redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g');
|
||||||
|
|
||||||
|
$this->assertSame(array('g', 'f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrangebylex('letters', '+', '-'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '-', '+'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('unknown', '-', '+'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('unknown', '+', '-'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group connected
|
||||||
|
* @requiresRedisVersion >= 2.8.9
|
||||||
|
*/
|
||||||
|
public function testReturnsElementsInInclusiveRange()
|
||||||
|
{
|
||||||
|
$redis = $this->getClient();
|
||||||
|
|
||||||
|
$redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g');
|
||||||
|
|
||||||
|
$this->assertSame(array('a'), $redis->zrevrangebylex('letters', '[a', '[a'));
|
||||||
|
$this->assertSame(array('f', 'e', 'd', 'c'), $redis->zrevrangebylex('letters', '[f', '[c'));
|
||||||
|
$this->assertSame(array('g', 'f', 'e'), $redis->zrevrangebylex('letters', '+', '[e'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '-', '[c'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '[z', '[x'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('unknown', '[1', '[0'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group connected
|
||||||
|
* @requiresRedisVersion >= 2.8.9
|
||||||
|
*/
|
||||||
|
public function testReturnsElementsInExclusiveRange()
|
||||||
|
{
|
||||||
|
$redis = $this->getClient();
|
||||||
|
|
||||||
|
$redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g');
|
||||||
|
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '(a', '(a'));
|
||||||
|
$this->assertSame(array('e', 'd'), $redis->zrevrangebylex('letters', '(f', '(c'));
|
||||||
|
$this->assertSame(array('g', 'f'), $redis->zrevrangebylex('letters', '+', '(e'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '-', '(c'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '(z', '(x'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('unknown', '(1', '(0'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group connected
|
||||||
|
* @requiresRedisVersion >= 2.8.9
|
||||||
|
*/
|
||||||
|
public function testReturnsElementsInMixedRange()
|
||||||
|
{
|
||||||
|
$redis = $this->getClient();
|
||||||
|
|
||||||
|
$redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g');
|
||||||
|
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '[a', '(a'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '(a', '[a'));
|
||||||
|
$this->assertSame(array('f', 'e', 'd'), $redis->zrevrangebylex('letters', '[f', '(c'));
|
||||||
|
$this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebylex('letters', '(f', '[c'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('unknown', '[5', '(0'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group connected
|
||||||
|
* @requiresRedisVersion >= 2.8.9
|
||||||
|
*/
|
||||||
|
public function testRangeWithLimitModifier()
|
||||||
|
{
|
||||||
|
$redis = $this->getClient();
|
||||||
|
|
||||||
|
$redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g');
|
||||||
|
|
||||||
|
$this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebylex('letters', '+', '-', 'LIMIT', '2', '3'));
|
||||||
|
$this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebylex('letters', '+', '-', array('limit' => array(2, 3))));
|
||||||
|
$this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebylex('letters', '+', '-', array('limit' => array('offset' => 2, 'count' => 3))));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '[f', '[a', 'LIMIT', '2', '0'));
|
||||||
|
$this->assertSame(array(), $redis->zrevrangebylex('letters', '[f', '[a', 'LIMIT', '-4', '2'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group connected
|
||||||
|
* @requiresRedisVersion >= 2.8.9
|
||||||
|
* @expectedException \Predis\Response\ServerException
|
||||||
|
* @expectedExceptionMessage min or max not valid string range item
|
||||||
|
*/
|
||||||
|
public function testThrowsExceptionOnInvalidRangeFormat()
|
||||||
|
{
|
||||||
|
$redis = $this->getClient();
|
||||||
|
|
||||||
|
$redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g');
|
||||||
|
$redis->zrevrangebylex('letters', 'f', 'b');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group connected
|
||||||
|
* @requiresRedisVersion >= 2.8.9
|
||||||
|
* @expectedException \Predis\Response\ServerException
|
||||||
|
* @expectedExceptionMessage Operation against a key holding the wrong kind of value
|
||||||
|
*/
|
||||||
|
public function testThrowsExceptionOnWrongType()
|
||||||
|
{
|
||||||
|
$redis = $this->getClient();
|
||||||
|
|
||||||
|
$redis->set('foo', 'bar');
|
||||||
|
$redis->zrevrangebylex('foo', '+', '-');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -181,12 +181,13 @@ class RedisUnstableTest extends PredisProfileTestCase
|
|||||||
140 => 'ZLEXCOUNT',
|
140 => 'ZLEXCOUNT',
|
||||||
141 => 'ZRANGEBYLEX',
|
141 => 'ZRANGEBYLEX',
|
||||||
142 => 'ZREMRANGEBYLEX',
|
142 => 'ZREMRANGEBYLEX',
|
||||||
143 => 'HSCAN',
|
143 => 'ZREVRANGEBYLEX',
|
||||||
144 => 'PUBSUB',
|
144 => 'HSCAN',
|
||||||
145 => 'PFADD',
|
145 => 'PUBSUB',
|
||||||
146 => 'PFCOUNT',
|
146 => 'PFADD',
|
||||||
147 => 'PFMERGE',
|
147 => 'PFCOUNT',
|
||||||
148 => 'COMMAND',
|
148 => 'PFMERGE',
|
||||||
|
149 => 'COMMAND',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,12 +181,13 @@ class RedisVersion280Test extends PredisProfileTestCase
|
|||||||
140 => 'ZLEXCOUNT',
|
140 => 'ZLEXCOUNT',
|
||||||
141 => 'ZRANGEBYLEX',
|
141 => 'ZRANGEBYLEX',
|
||||||
142 => 'ZREMRANGEBYLEX',
|
142 => 'ZREMRANGEBYLEX',
|
||||||
143 => 'HSCAN',
|
143 => 'ZREVRANGEBYLEX',
|
||||||
144 => 'PUBSUB',
|
144 => 'HSCAN',
|
||||||
145 => 'PFADD',
|
145 => 'PUBSUB',
|
||||||
146 => 'PFCOUNT',
|
146 => 'PFADD',
|
||||||
147 => 'PFMERGE',
|
147 => 'PFCOUNT',
|
||||||
148 => 'COMMAND',
|
148 => 'PFMERGE',
|
||||||
|
149 => 'COMMAND',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,12 +181,13 @@ class RedisVersion300Test extends PredisProfileTestCase
|
|||||||
140 => 'ZLEXCOUNT',
|
140 => 'ZLEXCOUNT',
|
||||||
141 => 'ZRANGEBYLEX',
|
141 => 'ZRANGEBYLEX',
|
||||||
142 => 'ZREMRANGEBYLEX',
|
142 => 'ZREMRANGEBYLEX',
|
||||||
143 => 'HSCAN',
|
143 => 'ZREVRANGEBYLEX',
|
||||||
144 => 'PUBSUB',
|
144 => 'HSCAN',
|
||||||
145 => 'PFADD',
|
145 => 'PUBSUB',
|
||||||
146 => 'PFCOUNT',
|
146 => 'PFADD',
|
||||||
147 => 'PFMERGE',
|
147 => 'PFCOUNT',
|
||||||
148 => 'COMMAND',
|
148 => 'PFMERGE',
|
||||||
|
149 => 'COMMAND',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ class ReplicationStrategyTest extends PredisTestCase
|
|||||||
'ZLEXCOUNT' => 'read',
|
'ZLEXCOUNT' => 'read',
|
||||||
'ZRANGEBYLEX' => 'read',
|
'ZRANGEBYLEX' => 'read',
|
||||||
'ZREMRANGEBYLEX' => 'write',
|
'ZREMRANGEBYLEX' => 'write',
|
||||||
|
'ZREVRANGEBYLEX' => 'read',
|
||||||
|
|
||||||
/* commands operating on hashes */
|
/* commands operating on hashes */
|
||||||
'HDEL' => 'write',
|
'HDEL' => 'write',
|
||||||
|
|||||||
Reference in New Issue
Block a user