mirror of
https://github.com/predis/predis.git
synced 2026-08-30 12:15:03 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bd961a767b | |||
| b3599a8e6b | |||
| 0b46de424e | |||
| 73bdfc2d72 | |||
| 3077e76708 | |||
| 208fdf6daf | |||
| 7d7995ff8f | |||
| 418197af75 | |||
| 90cb9d437d | |||
| 4668bdca83 | |||
| 93a3c184ed |
@@ -1,13 +1,21 @@
|
|||||||
v0.6.1 (2010-xx-xx)
|
v0.6.1 (2010-07-11)
|
||||||
|
* Minor internal improvements and clean ups.
|
||||||
|
|
||||||
* New commands available in the Redis v2.2 profile (dev):
|
* New commands available in the Redis v2.2 profile (dev):
|
||||||
- Misc. : WATCH, UNWATCH
|
- Misc. : WATCH, UNWATCH
|
||||||
|
|
||||||
* Minor internal improvements and clean ups.
|
* Optional modifiers for ZRANGE, ZREVRANGE and ZRANGEBYSCORE queries are
|
||||||
|
supported using an associative array passed as the last argument of their
|
||||||
|
respective methods.
|
||||||
|
|
||||||
* The constructor of Predis\Client::__construct now accepts also instances
|
* The LIMIT modifier for ZRANGEBYSCORE can be specified using either:
|
||||||
of Predis\ConnectionParameters.
|
- an indexed array: array($offset, $count)
|
||||||
|
- an associative array: array('offset' => $offset, 'count' => $count)
|
||||||
|
|
||||||
* Predis\MultiExecBlock and Predis\PubSubContext will throw an exception
|
* The method Predis\Client::__construct() now accepts also instances of
|
||||||
|
Predis\ConnectionParameters.
|
||||||
|
|
||||||
|
* Predis\MultiExecBlock and Predis\PubSubContext now throw an exception
|
||||||
when trying to create their instances using a profile that does not
|
when trying to create their instances using a profile that does not
|
||||||
support the required Redis commands or when the client is connected to
|
support the required Redis commands or when the client is connected to
|
||||||
a cluster of connections.
|
a cluster of connections.
|
||||||
@@ -17,14 +25,17 @@ v0.6.1 (2010-xx-xx)
|
|||||||
- support for WATCH and UNWATCH when using the current development
|
- support for WATCH and UNWATCH when using the current development
|
||||||
profile (Redis v2.2) and aborted transactions.
|
profile (Redis v2.2) and aborted transactions.
|
||||||
|
|
||||||
* New method signature for Predis\Client::multiExec(). Now it is able to
|
* New signature for Predis\Client::multiExec() which is now able to accept
|
||||||
accept an array of options for the underlying Predis\MultiExecBlock, but
|
an array of options for the underlying instance of Predis\MultiExecBlock.
|
||||||
it is still backwards compatible with previous releases of Predis.
|
Backwards compatibility with previous releases of Predis is ensured.
|
||||||
|
|
||||||
* New method signature for Predis\Client::pipeline(). Now it is able to
|
* New signature for Predis\Client::pipeline() which is now able to accept
|
||||||
accept an array of options for the underlying Predis\CommandPipeline,
|
an array of options for the underlying instance of Predis\CommandPipeline.
|
||||||
but it is still backwards compatible with previous releases of Predis.
|
Backwards compatibility with previous releases of Predis is ensured.
|
||||||
Predis\Client::pipelineSafe() is to be considered obsolete.
|
The method Predis\Client::pipelineSafe() is to be considered deprecated.
|
||||||
|
|
||||||
|
* FIX: The WEIGHT modifier for ZUNIONSTORE and ZINTERSTORE was handled
|
||||||
|
incorrectly with more than two weights specified.
|
||||||
|
|
||||||
v0.6.0 (2010-05-24)
|
v0.6.0 (2010-05-24)
|
||||||
* Switched to the new multi-bulk request protocol for all of the commands
|
* Switched to the new multi-bulk request protocol for all of the commands
|
||||||
|
|||||||
+47
-13
@@ -2550,8 +2550,9 @@ class ZSetUnionStore extends \Predis\MultiBulkCommand {
|
|||||||
$finalizedOpts = array();
|
$finalizedOpts = array();
|
||||||
if (isset($opts['WEIGHTS']) && is_array($opts['WEIGHTS'])) {
|
if (isset($opts['WEIGHTS']) && is_array($opts['WEIGHTS'])) {
|
||||||
$finalizedOpts[] = 'WEIGHTS';
|
$finalizedOpts[] = 'WEIGHTS';
|
||||||
$finalizedOpts[] = $opts['WEIGHTS'][0];
|
foreach ($opts['WEIGHTS'] as $weight) {
|
||||||
$finalizedOpts[] = $opts['WEIGHTS'][1];
|
$finalizedOpts[] = $weight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($opts['AGGREGATE'])) {
|
if (isset($opts['AGGREGATE'])) {
|
||||||
$finalizedOpts[] = 'AGGREGATE';
|
$finalizedOpts[] = 'AGGREGATE';
|
||||||
@@ -2566,20 +2567,42 @@ class ZSetIntersectionStore extends \Predis\Commands\ZSetUnionStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ZSetRange extends \Predis\MultiBulkCommand {
|
class ZSetRange extends \Predis\MultiBulkCommand {
|
||||||
|
private $_withScores = false;
|
||||||
public function getCommandId() { return 'ZRANGE'; }
|
public function getCommandId() { return 'ZRANGE'; }
|
||||||
public function parseResponse($data) {
|
public function filterArguments(Array $arguments) {
|
||||||
$arguments = $this->getArguments();
|
|
||||||
if (count($arguments) === 4) {
|
if (count($arguments) === 4) {
|
||||||
if (strtolower($arguments[3]) === 'withscores') {
|
$lastType = gettype($arguments[3]);
|
||||||
if ($data instanceof \Iterator) {
|
if ($lastType === 'string' && strtolower($arguments[3]) === 'withscores') {
|
||||||
return new \Predis\Shared\MultiBulkResponseKVIterator($data);
|
// used for compatibility with older versions
|
||||||
}
|
$arguments[3] = array('WITHSCORES' => true);
|
||||||
$result = array();
|
$lastType = 'array';
|
||||||
for ($i = 0; $i < count($data); $i++) {
|
|
||||||
$result[] = array($data[$i], $data[++$i]);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
if ($lastType === 'array') {
|
||||||
|
$options = $this->prepareOptions(array_pop($arguments));
|
||||||
|
return array_merge($arguments, $options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $arguments;
|
||||||
|
}
|
||||||
|
protected function prepareOptions($options) {
|
||||||
|
$opts = array_change_key_case($options, CASE_UPPER);
|
||||||
|
$finalizedOpts = array();
|
||||||
|
if (isset($opts['WITHSCORES'])) {
|
||||||
|
$finalizedOpts[] = 'WITHSCORES';
|
||||||
|
$this->_withScores = true;
|
||||||
|
}
|
||||||
|
return $finalizedOpts;
|
||||||
|
}
|
||||||
|
public function parseResponse($data) {
|
||||||
|
if ($this->_withScores) {
|
||||||
|
if ($data instanceof \Iterator) {
|
||||||
|
return new \Predis\Shared\MultiBulkResponseKVIterator($data);
|
||||||
|
}
|
||||||
|
$result = array();
|
||||||
|
for ($i = 0; $i < count($data); $i++) {
|
||||||
|
$result[] = array($data[$i], $data[++$i]);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@@ -2591,6 +2614,17 @@ class ZSetReverseRange extends \Predis\Commands\ZSetRange {
|
|||||||
|
|
||||||
class ZSetRangeByScore extends \Predis\Commands\ZSetRange {
|
class ZSetRangeByScore extends \Predis\Commands\ZSetRange {
|
||||||
public function getCommandId() { return 'ZRANGEBYSCORE'; }
|
public function getCommandId() { return 'ZRANGEBYSCORE'; }
|
||||||
|
protected function prepareOptions($options) {
|
||||||
|
$opts = array_change_key_case($options, CASE_UPPER);
|
||||||
|
$finalizedOpts = array();
|
||||||
|
if (isset($opts['LIMIT']) && is_array($opts['LIMIT'])) {
|
||||||
|
$limit = array_change_key_case($opts['LIMIT'], CASE_UPPER);
|
||||||
|
$finalizedOpts[] = 'LIMIT';
|
||||||
|
$finalizedOpts[] = isset($limit['OFFSET']) ? $limit['OFFSET'] : $limit[0];
|
||||||
|
$finalizedOpts[] = isset($limit['COUNT']) ? $limit['COUNT'] : $limit[1];
|
||||||
|
}
|
||||||
|
return array_merge($finalizedOpts, parent::prepareOptions($options));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ZSetCount extends \Predis\MultiBulkCommand {
|
class ZSetCount extends \Predis\MultiBulkCommand {
|
||||||
|
|||||||
@@ -1095,6 +1095,11 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
|||||||
$this->redis->zrange('zset', 0, 2, 'withscores')
|
$this->redis->zrange('zset', 0, 2, 'withscores')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array(array('a', -10), array('b', 0), array('c', 10)),
|
||||||
|
$this->redis->zrange('zset', 0, 2, array('withscores' => true))
|
||||||
|
);
|
||||||
|
|
||||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||||
$test->redis->set('foo', 'bar');
|
$test->redis->set('foo', 'bar');
|
||||||
$test->redis->zrange('foo', 0, -1);
|
$test->redis->zrange('foo', 0, -1);
|
||||||
@@ -1149,6 +1154,11 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
|||||||
$this->redis->zrevrange('zset', 0, 2, 'withscores')
|
$this->redis->zrevrange('zset', 0, 2, 'withscores')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array(array('f', 30), array('e', 20), array('d', 20)),
|
||||||
|
$this->redis->zrevrange('zset', 0, 2, array('withscores' => true))
|
||||||
|
);
|
||||||
|
|
||||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||||
$test->redis->set('foo', 'bar');
|
$test->redis->set('foo', 'bar');
|
||||||
$test->redis->zrevrange('foo', 0, -1);
|
$test->redis->zrevrange('foo', 0, -1);
|
||||||
@@ -1183,6 +1193,31 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
|||||||
$this->redis->zrangebyscore('zset', 10, 20, 'withscores')
|
$this->redis->zrangebyscore('zset', 10, 20, 'withscores')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array(array('c', 10), array('d', 20), array('e', 20)),
|
||||||
|
$this->redis->zrangebyscore('zset', 10, 20, array('withscores' => true))
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array('d', 'e'),
|
||||||
|
$this->redis->zrangebyscore('zset', 10, 20, array('limit' => array(1, 2)))
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array('d', 'e'),
|
||||||
|
$this->redis->zrangebyscore('zset', 10, 20, array(
|
||||||
|
'limit' => array('offset' => 1, 'count' => 2)
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array(array('d', 20), array('e', 20)),
|
||||||
|
$this->redis->zrangebyscore('zset', 10, 20, array(
|
||||||
|
'limit' => array(1, 2),
|
||||||
|
'withscores' => true,
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||||
$test->redis->set('foo', 'bar');
|
$test->redis->set('foo', 'bar');
|
||||||
$test->redis->zrangebyscore('foo', 0, 0);
|
$test->redis->zrangebyscore('foo', 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user