mirror of
https://github.com/predis/predis.git
synced 2026-08-17 18:45:16 +00:00
Compare commits
11 Commits
v2.4.0-RC1
...
v0.6.1
| 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):
|
||||
- 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
|
||||
of Predis\ConnectionParameters.
|
||||
* The LIMIT modifier for ZRANGEBYSCORE can be specified using either:
|
||||
- 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
|
||||
support the required Redis commands or when the client is connected to
|
||||
a cluster of connections.
|
||||
@@ -17,14 +25,17 @@ v0.6.1 (2010-xx-xx)
|
||||
- support for WATCH and UNWATCH when using the current development
|
||||
profile (Redis v2.2) and aborted transactions.
|
||||
|
||||
* New method signature for Predis\Client::multiExec(). Now it is able to
|
||||
accept an array of options for the underlying Predis\MultiExecBlock, but
|
||||
it is still backwards compatible with previous releases of Predis.
|
||||
* New signature for Predis\Client::multiExec() which is now able to accept
|
||||
an array of options for the underlying instance of Predis\MultiExecBlock.
|
||||
Backwards compatibility with previous releases of Predis is ensured.
|
||||
|
||||
* New method signature for Predis\Client::pipeline(). Now it is able to
|
||||
accept an array of options for the underlying Predis\CommandPipeline,
|
||||
but it is still backwards compatible with previous releases of Predis.
|
||||
Predis\Client::pipelineSafe() is to be considered obsolete.
|
||||
* New signature for Predis\Client::pipeline() which is now able to accept
|
||||
an array of options for the underlying instance of Predis\CommandPipeline.
|
||||
Backwards compatibility with previous releases of Predis is ensured.
|
||||
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)
|
||||
* 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();
|
||||
if (isset($opts['WEIGHTS']) && is_array($opts['WEIGHTS'])) {
|
||||
$finalizedOpts[] = 'WEIGHTS';
|
||||
$finalizedOpts[] = $opts['WEIGHTS'][0];
|
||||
$finalizedOpts[] = $opts['WEIGHTS'][1];
|
||||
foreach ($opts['WEIGHTS'] as $weight) {
|
||||
$finalizedOpts[] = $weight;
|
||||
}
|
||||
}
|
||||
if (isset($opts['AGGREGATE'])) {
|
||||
$finalizedOpts[] = 'AGGREGATE';
|
||||
@@ -2566,20 +2567,42 @@ class ZSetIntersectionStore extends \Predis\Commands\ZSetUnionStore {
|
||||
}
|
||||
|
||||
class ZSetRange extends \Predis\MultiBulkCommand {
|
||||
private $_withScores = false;
|
||||
public function getCommandId() { return 'ZRANGE'; }
|
||||
public function parseResponse($data) {
|
||||
$arguments = $this->getArguments();
|
||||
public function filterArguments(Array $arguments) {
|
||||
if (count($arguments) === 4) {
|
||||
if (strtolower($arguments[3]) === '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;
|
||||
$lastType = gettype($arguments[3]);
|
||||
if ($lastType === 'string' && strtolower($arguments[3]) === 'withscores') {
|
||||
// used for compatibility with older versions
|
||||
$arguments[3] = array('WITHSCORES' => true);
|
||||
$lastType = 'array';
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -2591,6 +2614,17 @@ class ZSetReverseRange extends \Predis\Commands\ZSetRange {
|
||||
|
||||
class ZSetRangeByScore extends \Predis\Commands\ZSetRange {
|
||||
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 {
|
||||
|
||||
@@ -1095,6 +1095,11 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$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) {
|
||||
$test->redis->set('foo', 'bar');
|
||||
$test->redis->zrange('foo', 0, -1);
|
||||
@@ -1149,6 +1154,11 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$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) {
|
||||
$test->redis->set('foo', 'bar');
|
||||
$test->redis->zrevrange('foo', 0, -1);
|
||||
@@ -1183,6 +1193,31 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$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) {
|
||||
$test->redis->set('foo', 'bar');
|
||||
$test->redis->zrangebyscore('foo', 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user