Remove trailing spaces in code.

This commit is contained in:
Daniele Alessandri
2011-02-15 12:46:19 +01:00
parent af03916369
commit 2b2ca8e8dc
10 changed files with 149 additions and 149 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require_once 'SharedConfigurations.php';
// When you have a whole set of consecutive commands to send to
// When you have a whole set of consecutive commands to send to
// a redis server, you can use a pipeline to improve performances.
$redis = new Predis\Client($single_server);
+3 -3
View File
@@ -1,8 +1,8 @@
<?php
require_once 'SharedConfigurations.php';
// Developers can customize the distribution strategy used by the client
// to distribute keys among a cluster of servers simply by creating a class
// Developers can customize the distribution strategy used by the client
// to distribute keys among a cluster of servers simply by creating a class
// that implements the Predis\Distribution\IDistributionStrategy interface.
class NaiveDistributionStrategy
@@ -54,7 +54,7 @@ for ($i = 0; $i < 100; $i++) {
$server1 = $redis->getClientFor('first')->info();
$server2 = $redis->getClientFor('second')->info();
printf("Server '%s' has %d keys while server '%s' has %d keys.\n",
printf("Server '%s' has %d keys while server '%s' has %d keys.\n",
'first', $server1['db15']['keys'], 'second', $server2['db15']['keys']
);
?>
+3 -3
View File
@@ -2,8 +2,8 @@
require_once 'SharedConfigurations.php';
/*
This is an implementation of an atomic client-side ZPOP using the support for
check-and-set (CAS) operations with MULTI/EXEC transactions, as described in
This is an implementation of an atomic client-side ZPOP using the support for
check-and-set (CAS) operations with MULTI/EXEC transactions, as described in
"WATCH explained" from http://redis.io/topics/transactions
First, populate your database with a tiny sample data set:
@@ -24,7 +24,7 @@ function zpop($client, $zsetKey) {
// which the client bails out with an exception.
);
$txReply = $client->multiExec($options, function($tx)
$txReply = $client->multiExec($options, function($tx)
use ($zsetKey, &$element) {
@list($element) = $tx->zrange($zsetKey, 0, 0);
if (isset($element)) {
+4 -4
View File
@@ -1,14 +1,14 @@
<?php
require_once 'SharedConfigurations.php';
// redis can set keys and their relative values in one go
// using MSET, then the same values can be retrieved with
// redis can set keys and their relative values in one go
// using MSET, then the same values can be retrieved with
// a single command using MGET.
$mkv = array(
'usr:0001' => 'First user',
'usr:0002' => 'Second user',
'usr:0003' => 'Third user'
'usr:0002' => 'Second user',
'usr:0003' => 'Third user'
);
$redis = new Predis\Client($single_server);
+4 -4
View File
@@ -1,7 +1,7 @@
<?php
require_once 'SharedConfigurations.php';
// Redis 2.0 features new commands that allow clients to subscribe for
// Redis 2.0 features new commands that allow clients to subscribe for
// events published on certain channels (PUBSUB).
// Create a client and disable r/w timeout on the socket
@@ -14,7 +14,7 @@ $pubsub = $redis->pubSubContext();
$pubsub->subscribe('control_channel');
$pubsub->subscribe('notifications');
// Start processing the pubsup messages. Open a terminal and use redis-cli
// Start processing the pubsup messages. Open a terminal and use redis-cli
// to push messages to the channels. Examples:
// ./redis-cli PUBLISH notifications "this is a test"
// ./redis-cli PUBLISH control_channel quit_loop
@@ -41,8 +41,8 @@ foreach ($pubsub as $message) {
}
}
// Always unset the pubsub context instance when you are done! The
// class destructor will take care of cleanups and prevent protocol
// Always unset the pubsub context instance when you are done! The
// class destructor will take care of cleanups and prevent protocol
// desynchronizations between the client and the server.
unset($pubsub);
+2 -2
View File
@@ -2,8 +2,8 @@
require_once '../lib/Predis.php';
$single_server = array(
'host' => '127.0.0.1',
'port' => 6379,
'host' => '127.0.0.1',
'port' => 6379,
'database' => 15
);
+3 -3
View File
@@ -192,7 +192,7 @@ class Client {
if (isset($options)) {
if (isset($options['safe']) && $options['safe'] == true) {
$connection = $this->_connection;
$pipeline = new CommandPipeline($this,
$pipeline = new CommandPipeline($this,
Utils::isCluster($connection)
? new Pipeline\SafeClusterExecutor($connection)
: new Pipeline\SafeExecutor($connection)
@@ -741,7 +741,7 @@ class CommunicationException extends PredisException {
// Communication errors
private $_connection;
public function __construct(IConnectionSingle $connection,
public function __construct(IConnectionSingle $connection,
$message = null, $code = null) {
$this->_connection = $connection;
@@ -3224,7 +3224,7 @@ class Sort extends Command {
$query[] = $getargs;
}
}
if (isset($sortParams['LIMIT']) && is_array($sortParams['LIMIT'])
if (isset($sortParams['LIMIT']) && is_array($sortParams['LIMIT'])
&& count($sortParams['LIMIT']) == 2) {
$query[] = 'LIMIT';
+16 -16
View File
@@ -4,12 +4,12 @@ require_once 'PredisShared.php';
class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
public $redis;
protected function setUp() {
protected function setUp() {
$this->redis = RC::getConnection();
$this->redis->flushdb();
}
protected function tearDown() {
protected function tearDown() {
}
protected function onNotSuccessfulTest(Exception $exception) {
@@ -141,7 +141,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$bogusCommand = 'not_existing_command';
$expectedMessage = "'$bogusCommand' is not a registered Redis command";
RC::testForClientException($this, $expectedMessage, function()
RC::testForClientException($this, $expectedMessage, function()
use($profile, $bogusCommand) {
$profile->createCommand($bogusCommand);
@@ -291,7 +291,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$connection = new \Predis\Network\TcpConnection(RC::getConnectionParameters(), $protocol);
$reader->setHandler(
\Predis\Protocols\TextProtocol::PREFIX_MULTI_BULK,
\Predis\Protocols\TextProtocol::PREFIX_MULTI_BULK,
new \Predis\Protocols\ResponseMultiBulkHandler()
);
$connection->writeBytes("KEYS *\r\n");
@@ -315,7 +315,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$reader->read($connection);
$reader->setHandler(
\Predis\Protocols\TextProtocol::PREFIX_ERROR,
\Predis\Protocols\TextProtocol::PREFIX_ERROR,
new \Predis\Protocols\ResponseErrorSilentHandler()
);
$connection->writeBytes($rawCmdUnexpected);
@@ -324,10 +324,10 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$this->assertEquals(RC::EXCEPTION_WRONG_TYPE, $errorReply->message);
$reader->setHandler(
\Predis\Protocols\TextProtocol::PREFIX_ERROR,
\Predis\Protocols\TextProtocol::PREFIX_ERROR,
new \Predis\Protocols\ResponseErrorHandler()
);
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function()
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function()
use ($connection, $rawCmdUnexpected) {
$connection->writeBytes($rawCmdUnexpected);
@@ -430,7 +430,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client = RC::getConnection();
$client->flushdb();
$replies = $client->pipeline(function($pipe) {
$replies = $client->pipeline(function($pipe) {
$pipe->ping();
$pipe->set('foo', 'bar');
$pipe->get('foo');
@@ -459,7 +459,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client->flushdb();
$client->getConnection()->getProtocol()->setOption('throw_on_error', false);
$replies = $client->pipeline(function($pipe) {
$replies = $client->pipeline(function($pipe) {
$pipe->set('foo', 'bar');
$pipe->lpush('foo', 'piyo'); // LIST operation on STRING type returns an ERROR
$pipe->set('hoge', 'piyo');
@@ -526,7 +526,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client = RC::getConnection();
$client->flushdb();
$replies = $client->multiExec(function($multi) {
$replies = $client->multiExec(function($multi) {
$multi->ping();
$multi->set('foo', 'bar');
$multi->get('foo');
@@ -567,7 +567,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client->flushdb();
RC::testForClientException($this, 'TEST', function() use($client) {
$client->multiExec(function($multi) {
$client->multiExec(function($multi) {
$multi->ping();
$multi->set('foo', 'bar');
throw new \Predis\ClientException("TEST");
@@ -581,7 +581,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client->flushdb();
$client->getConnection()->getProtocol()->setOption('throw_on_error', false);
$replies = $client->multiExec(function($multi) {
$replies = $client->multiExec(function($multi) {
$multi->set('foo', 'bar');
$multi->lpush('foo', 'piyo'); // LIST operation on STRING type returns an ERROR
$multi->set('hoge', 'piyo');
@@ -597,7 +597,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client = RC::getConnection();
$client->flushdb();
$replies = $client->multiExec(function($multi) {
$replies = $client->multiExec(function($multi) {
$multi->set('foo', 'bar');
$multi->discard();
$multi->set('hoge', 'piyo');
@@ -612,7 +612,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client = RC::getConnection();
$client->flushdb();
$replies = $client->multiExec(function($multi) {
$replies = $client->multiExec(function($multi) {
$multi->discard();
});
@@ -624,10 +624,10 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client2 = RC::getConnection(true);
$client1->flushdb();
RC::testForAbortedMultiExecException($this, function()
RC::testForAbortedMultiExecException($this, function()
use($client1, $client2) {
$client1->multiExec(array('watch' => 'sentinel'), function($multi)
$client1->multiExec(array('watch' => 'sentinel'), function($multi)
use ($client2) {
$multi->set('sentinel', 'client1');
+12 -12
View File
@@ -7,7 +7,7 @@ define('I_AM_AWARE_OF_THE_DESTRUCTIVE_POWER_OF_THIS_TEST_SUITE', false);
if (I_AM_AWARE_OF_THE_DESTRUCTIVE_POWER_OF_THIS_TEST_SUITE !== true) {
exit(
"Please set the I_AM_AWARE_OF_THE_DESTRUCTIVE_POWER_OF_THIS_TEST_SUITE " .
"Please set the I_AM_AWARE_OF_THE_DESTRUCTIVE_POWER_OF_THIS_TEST_SUITE " .
"constant to TRUE in PredisShared.php if you want to proceed.\n"
);
}
@@ -16,7 +16,7 @@ require_once 'PHPUnit/Framework.php';
require_once '../lib/Predis.php';
if (!function_exists('array_union')) {
function array_union(Array $a, Array $b) {
function array_union(Array $a, Array $b) {
return array_merge($a, array_diff($b, $a));
}
}
@@ -41,11 +41,11 @@ class RC {
private static $_connection;
public static function getConnectionArguments() {
public static function getConnectionArguments() {
return array('host' => RC::SERVER_HOST, 'port' => RC::SERVER_PORT);
}
public static function getConnectionParameters() {
public static function getConnectionParameters() {
return new Predis\ConnectionParameters(array('host' => RC::SERVER_HOST, 'port' => RC::SERVER_PORT));
}
@@ -75,7 +75,7 @@ class RC {
}
public static function helperForBlockingPops($op) {
// TODO: I admit that this helper is kinda lame and it does not run
// TODO: I admit that this helper is kinda lame and it does not run
// in a separate process to properly test BLPOP/BRPOP
$redisUri = sprintf('redis://%s:%d/?database=%d', RC::SERVER_HOST, RC::SERVER_PORT, RC::DEFAULT_DATABASE);
$handle = popen('php', 'w');
@@ -96,17 +96,17 @@ class RC {
public static function getKeyValueArray() {
return array(
'foo' => 'bar',
'hoge' => 'piyo',
'foofoo' => 'barbar',
'foo' => 'bar',
'hoge' => 'piyo',
'foofoo' => 'barbar',
);
}
public static function getNamespacedKeyValueArray() {
return array(
'metavar:foo' => 'bar',
'metavar:hoge' => 'piyo',
'metavar:foofoo' => 'barbar',
'metavar:foo' => 'bar',
'metavar:hoge' => 'piyo',
'metavar:foofoo' => 'barbar',
);
}
@@ -209,7 +209,7 @@ class RC {
public static function getConnectionParametersArgumentsArray() {
return array(
'host' => '10.0.0.1', 'port' => 6380, 'connection_timeout' => 10, 'read_write_timeout' => 30,
'host' => '10.0.0.1', 'port' => 6380, 'connection_timeout' => 10, 'read_write_timeout' => 30,
'database' => 5, 'password' => 'dbpassword', 'alias' => 'connection_alias'
);
}
+101 -101
View File
@@ -4,8 +4,8 @@ require_once 'PredisShared.php';
class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
public $redis;
// TODO: instead of an boolean assertion against the return value
// of RC::sameValuesInArrays, we should extend PHPUnit with
// TODO: instead of an boolean assertion against the return value
// of RC::sameValuesInArrays, we should extend PHPUnit with
// a new assertion, e.g. $this->assertSameValues();
// TODO: an option to skip certain tests such as testflushdbs
// should be provided.
@@ -43,9 +43,9 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
}
function testMultiExec() {
// NOTE: due to a limitation in the current implementation of Predis\Client,
// the replies returned by Predis\Command\Exec are not parsed by their
// respective Predis\Command::parseResponse methods. If you need that
// NOTE: due to a limitation in the current implementation of Predis\Client,
// the replies returned by Predis\Command\Exec are not parsed by their
// respective Predis\Command::parseResponse methods. If you need that
// kind of behaviour, you should use an instance of Predis\MultiExecBlock.
$this->assertTrue($this->redis->multi());
$this->assertType('Predis\ResponseQueued', $this->redis->ping());
@@ -138,7 +138,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->redis->mset($multi);
$this->assertTrue($this->redis->msetnx($newpair));
$this->assertEquals(
array_values($expectedResult),
array_values($expectedResult),
$this->redis->mget(array_keys($expectedResult))
);
@@ -149,7 +149,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->redis->mset($multi);
$this->assertFalse($this->redis->msetnx(array_merge($newpair, $hijacked)));
$this->assertEquals(
array_values($expectedResult),
array_values($expectedResult),
$this->redis->mget(array_keys($expectedResult))
);
}
@@ -581,35 +581,35 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$numbers = RC::pushTailAndReturn($this->redis, 'numbers', RC::getArrayOfNumbers());
$this->assertTrue($this->redis->ltrim('numbers', 0, 2));
$this->assertEquals(
array_slice($numbers, 0, 3),
array_slice($numbers, 0, 3),
$this->redis->lrange('numbers', 0, -1)
);
$numbers = RC::pushTailAndReturn($this->redis, 'numbers', RC::getArrayOfNumbers(), RC::WIPE_OUT);
$this->assertTrue($this->redis->ltrim('numbers', 5, 9));
$this->assertEquals(
array_slice($numbers, 5, 5),
array_slice($numbers, 5, 5),
$this->redis->lrange('numbers', 0, -1)
);
$numbers = RC::pushTailAndReturn($this->redis, 'numbers', RC::getArrayOfNumbers(), RC::WIPE_OUT);
$this->assertTrue($this->redis->ltrim('numbers', 0, -6));
$this->assertEquals(
array_slice($numbers, 0, -5),
array_slice($numbers, 0, -5),
$this->redis->lrange('numbers', 0, -1)
);
$numbers = RC::pushTailAndReturn($this->redis, 'numbers', RC::getArrayOfNumbers(), RC::WIPE_OUT);
$this->assertTrue($this->redis->ltrim('numbers', -5, -3));
$this->assertEquals(
array_slice($numbers, 5, 3),
array_slice($numbers, 5, 3),
$this->redis->lrange('numbers', 0, -1)
);
$numbers = RC::pushTailAndReturn($this->redis, 'numbers', RC::getArrayOfNumbers(), RC::WIPE_OUT);
$this->assertTrue($this->redis->ltrim('numbers', -100, 100));
$this->assertEquals(
$numbers,
$numbers,
$this->redis->lrange('numbers', 0, -1)
);
@@ -758,8 +758,8 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
}
function testListBlockingPopFirst() {
// TODO: this test does not cover all the aspects of BLPOP/BRPOP as it
// does not run with a concurrent client pushing items on lists.
// TODO: this test does not cover all the aspects of BLPOP/BRPOP as it
// does not run with a concurrent client pushing items on lists.
RC::helperForBlockingPops('blpop');
// BLPOP on one key
@@ -785,8 +785,8 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
}
function testListBlockingPopLast() {
// TODO: this test does not cover all the aspects of BLPOP/BRPOP as it
// does not run with a concurrent client pushing items on lists.
// TODO: this test does not cover all the aspects of BLPOP/BRPOP as it
// does not run with a concurrent client pushing items on lists.
RC::helperForBlockingPops('brpop');
// BRPOP on one key
@@ -972,7 +972,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
));
$this->assertTrue(RC::sameValuesInArrays(
array_intersect($setA, $setB),
array_intersect($setA, $setB),
$this->redis->sinter('setA', 'setB')
));
@@ -994,14 +994,14 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->assertEquals(count($setA), $this->redis->sinterstore('setC', 'setA'));
$this->assertTrue(RC::sameValuesInArrays(
$setA,
$setA,
$this->redis->smembers('setC')
));
$this->redis->del('setC');
$this->assertEquals(4, $this->redis->sinterstore('setC', 'setA', 'setB'));
$this->assertTrue(RC::sameValuesInArrays(
array(1, 3, 4, 6),
array(1, 3, 4, 6),
$this->redis->smembers('setC')
));
@@ -1025,17 +1025,17 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$setB = RC::setAddAndReturn($this->redis, 'setB', array(1, 3, 4, 6, 9, 10));
$this->assertTrue(RC::sameValuesInArrays(
$setA,
$setA,
$this->redis->sunion('setA')
));
$this->assertTrue(RC::sameValuesInArrays(
array_union($setA, $setB),
array_union($setA, $setB),
$this->redis->sunion('setA', 'setB')
));
$this->assertTrue(RC::sameValuesInArrays(
$setA,
$setA,
$this->redis->sunion('setA', 'setDoesNotExist')
));
@@ -1055,14 +1055,14 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->assertEquals(count($setA), $this->redis->sunionstore('setC', 'setA'));
$this->assertTrue(RC::sameValuesInArrays(
$setA,
$setA,
$this->redis->smembers('setC')
));
$this->redis->del('setC');
$this->assertEquals(9, $this->redis->sunionstore('setC', 'setA', 'setB'));
$this->assertTrue(RC::sameValuesInArrays(
array_union($setA, $setB),
array_union($setA, $setB),
$this->redis->smembers('setC')
));
@@ -1088,17 +1088,17 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$setB = RC::setAddAndReturn($this->redis, 'setB', array(1, 3, 4, 6, 9, 10));
$this->assertTrue(RC::sameValuesInArrays(
$setA,
$setA,
$this->redis->sdiff('setA')
));
$this->assertTrue(RC::sameValuesInArrays(
array_diff($setA, $setB),
array_diff($setA, $setB),
$this->redis->sdiff('setA', 'setB')
));
$this->assertTrue(RC::sameValuesInArrays(
$setA,
$setA,
$this->redis->sdiff('setA', 'setDoesNotExist')
));
@@ -1118,14 +1118,14 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->assertEquals(count($setA), $this->redis->sdiffstore('setC', 'setA'));
$this->assertTrue(RC::sameValuesInArrays(
$setA,
$setA,
$this->redis->smembers('setC')
));
$this->redis->del('setC');
$this->assertEquals(3, $this->redis->sdiffstore('setC', 'setA', 'setB'));
$this->assertTrue(RC::sameValuesInArrays(
array_diff($setA, $setB),
array_diff($setA, $setB),
$this->redis->smembers('setC')
));
@@ -1204,7 +1204,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
function testZsetRemove() {
RC::zsetAddAndReturn($this->redis, 'zset', RC::getZSetArray());
$this->assertTrue($this->redis->zrem('zset', 'a'));
$this->assertFalse($this->redis->zrem('zset', 'x'));
@@ -1218,57 +1218,57 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$zset = RC::zsetAddAndReturn($this->redis, 'zset', RC::getZSetArray());
$this->assertEquals(
array_slice(array_keys($zset), 0, 4),
array_slice(array_keys($zset), 0, 4),
$this->redis->zrange('zset', 0, 3)
);
$this->assertEquals(
array_slice(array_keys($zset), 0, 1),
array_slice(array_keys($zset), 0, 1),
$this->redis->zrange('zset', 0, 0)
);
$this->assertEquals(
array(),
array(),
$this->redis->zrange('zset', 1, 0)
);
$this->assertEquals(
array_values(array_keys($zset)),
array_values(array_keys($zset)),
$this->redis->zrange('zset', 0, -1)
);
$this->assertEquals(
array_slice(array_keys($zset), 3, 1),
array_slice(array_keys($zset), 3, 1),
$this->redis->zrange('zset', 3, -3)
);
$this->assertEquals(
array(),
array(),
$this->redis->zrange('zset', 5, -3)
);
$this->assertEquals(
array_slice(array_keys($zset), -5, -1),
array_slice(array_keys($zset), -5, -1),
$this->redis->zrange('zset', -5, -2)
);
$this->assertEquals(
array_values(array_keys($zset)),
array_values(array_keys($zset)),
$this->redis->zrange('zset', -100, 100)
);
$this->assertEquals(
array_values(array_keys($zset)),
array_values(array_keys($zset)),
$this->redis->zrange('zset', -100, 100)
);
$this->assertEquals(
array(array('a', -10), array('b', 0), array('c', 10)),
array(array('a', -10), array('b', 0), array('c', 10)),
$this->redis->zrange('zset', 0, 2, 'withscores')
);
$this->assertEquals(
array(array('a', -10), array('b', 0), array('c', 10)),
array(array('a', -10), array('b', 0), array('c', 10)),
$this->redis->zrange('zset', 0, 2, array('withscores' => true))
);
@@ -1282,52 +1282,52 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$zset = RC::zsetAddAndReturn($this->redis, 'zset', RC::getZSetArray());
$this->assertEquals(
array_slice(array_reverse(array_keys($zset)), 0, 4),
array_slice(array_reverse(array_keys($zset)), 0, 4),
$this->redis->zrevrange('zset', 0, 3)
);
$this->assertEquals(
array_slice(array_reverse(array_keys($zset)), 0, 1),
array_slice(array_reverse(array_keys($zset)), 0, 1),
$this->redis->zrevrange('zset', 0, 0)
);
$this->assertEquals(
array(),
array(),
$this->redis->zrevrange('zset', 1, 0)
);
$this->assertEquals(
array_values(array_reverse(array_keys($zset))),
array_values(array_reverse(array_keys($zset))),
$this->redis->zrevrange('zset', 0, -1)
);
$this->assertEquals(
array_slice(array_reverse(array_keys($zset)), 3, 1),
array_slice(array_reverse(array_keys($zset)), 3, 1),
$this->redis->zrevrange('zset', 3, -3)
);
$this->assertEquals(
array(),
array(),
$this->redis->zrevrange('zset', 5, -3)
);
$this->assertEquals(
array_slice(array_reverse(array_keys($zset)), -5, -1),
array_slice(array_reverse(array_keys($zset)), -5, -1),
$this->redis->zrevrange('zset', -5, -2)
);
$this->assertEquals(
array_values(array_reverse(array_keys($zset))),
array_values(array_reverse(array_keys($zset))),
$this->redis->zrevrange('zset', -100, 100)
);
$this->assertEquals(
array(array('f', 30), array('e', 20), array('d', 20)),
array(array('f', 30), array('e', 20), array('d', 20)),
$this->redis->zrevrange('zset', 0, 2, 'withscores')
);
$this->assertEquals(
array(array('f', 30), array('e', 20), array('d', 20)),
array(array('f', 30), array('e', 20), array('d', 20)),
$this->redis->zrevrange('zset', 0, 2, array('withscores' => true))
);
@@ -1346,47 +1346,47 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
);
$this->assertEquals(
array('c', 'd', 'e', 'f'),
array('c', 'd', 'e', 'f'),
$this->redis->zrangebyscore('zset', 10, 30)
);
$this->assertEquals(
array('d', 'e'),
array('d', 'e'),
$this->redis->zrangebyscore('zset', 20, 20)
);
$this->assertEquals(
array(),
array(),
$this->redis->zrangebyscore('zset', 30, 0)
);
$this->assertEquals(
array(array('c', 10), array('d', 20), array('e', 20)),
array(array('c', 10), array('d', 20), array('e', 20)),
$this->redis->zrangebyscore('zset', 10, 20, 'withscores')
);
$this->assertEquals(
array(array('c', 10), array('d', 20), array('e', 20)),
array(array('c', 10), array('d', 20), array('e', 20)),
$this->redis->zrangebyscore('zset', 10, 20, array('withscores' => true))
);
$this->assertEquals(
array('d', 'e'),
array('d', 'e'),
$this->redis->zrangebyscore('zset', 10, 20, array('limit' => array(1, 2)))
);
$this->assertEquals(
array('d', 'e'),
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)),
array(array('d', 20), array('e', 20)),
$this->redis->zrangebyscore('zset', 10, 20, array(
'limit' => array(1, 2),
'withscores' => true,
'limit' => array(1, 2),
'withscores' => true,
))
);
@@ -1400,52 +1400,52 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$zset = RC::zsetAddAndReturn($this->redis, 'zset', RC::getZSetArray());
$this->assertEquals(
array('a'),
array('a'),
$this->redis->zrevrangebyscore('zset', -10, -10)
);
$this->assertEquals(
array('b', 'a'),
array('b', 'a'),
$this->redis->zrevrangebyscore('zset', 0, -10)
);
$this->assertEquals(
array('e', 'd'),
array('e', 'd'),
$this->redis->zrevrangebyscore('zset', 20, 20)
);
$this->assertEquals(
array('f', 'e', 'd', 'c', 'b'),
array('f', 'e', 'd', 'c', 'b'),
$this->redis->zrevrangebyscore('zset', 30, 0)
);
$this->assertEquals(
array(array('e', 20), array('d', 20), array('c', 10)),
array(array('e', 20), array('d', 20), array('c', 10)),
$this->redis->zrevrangebyscore('zset', 20, 10, 'withscores')
);
$this->assertEquals(
array(array('e', 20), array('d', 20), array('c', 10)),
array(array('e', 20), array('d', 20), array('c', 10)),
$this->redis->zrevrangebyscore('zset', 20, 10, array('withscores' => true))
);
$this->assertEquals(
array('d', 'c'),
array('d', 'c'),
$this->redis->zrevrangebyscore('zset', 20, 10, array('limit' => array(1, 2)))
);
$this->assertEquals(
array('d', 'c'),
array('d', 'c'),
$this->redis->zrevrangebyscore('zset', 20, 10, array(
'limit' => array('offset' => 1, 'count' => 2)
))
);
$this->assertEquals(
array(array('d', 20), array('c', 10)),
array(array('d', 20), array('c', 10)),
$this->redis->zrevrangebyscore('zset', 20, 10, array(
'limit' => array(1, 2),
'withscores' => true,
'limit' => array(1, 2),
'withscores' => true,
))
);
@@ -1462,19 +1462,19 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
// 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)),
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->zunionstore('zsetc', 2, 'zseta', 'zsetbNull'));
$this->assertEquals(
array(array('a', 1), array('b', 2), array('c', 3)),
array(array('a', 1), array('b', 2), array('c', 3)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
$this->assertEquals(3, $this->redis->zunionstore('zsetc', 2, 'zsetaNull', 'zsetb'));
$this->assertEquals(
array(array('b', 1), array('c', 2), array('d', 3)),
array(array('b', 1), array('c', 2), array('d', 3)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
@@ -1484,7 +1484,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$options = array('weights' => array(2, 3));
$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)),
array(array('a', 2), array('b', 7), array('d', 9), array('c', 12)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
@@ -1492,7 +1492,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$options = array('aggregate' => 'min');
$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)),
array(array('a', 1), array('b', 1), array('c', 2), array('d', 3)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
@@ -1500,7 +1500,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$options = array('aggregate' => 'max');
$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)),
array(array('a', 1), array('b', 2), array('c', 3), array('d', 3)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
@@ -1517,7 +1517,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
// basic ZINTERSTORE
$this->assertEquals(2, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetb'));
$this->assertEquals(
array(array('b', 3), array('c', 5)),
array(array('b', 3), array('c', 5)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
@@ -1529,7 +1529,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$options = array('weights' => array(2, 3));
$this->assertEquals(2, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetb', $options));
$this->assertEquals(
array(array('b', 7), array('c', 12)),
array(array('b', 7), array('c', 12)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
@@ -1537,7 +1537,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$options = array('aggregate' => 'min');
$this->assertEquals(2, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetb', $options));
$this->assertEquals(
array(array('b', 1), array('c', 2)),
array(array('b', 1), array('c', 2)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
@@ -1545,7 +1545,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$options = array('aggregate' => 'max');
$this->assertEquals(2, $this->redis->zinterstore('zsetc', 2, 'zseta', 'zsetb', $options));
$this->assertEquals(
array(array('b', 2), array('c', 3)),
array(array('b', 2), array('c', 3)),
$this->redis->zrange('zsetc', 0, -1, 'withscores')
);
@@ -1576,7 +1576,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$zset = RC::zsetAddAndReturn($this->redis, 'zset', RC::getZSetArray());
$this->assertEquals(count($zset), $this->redis->zcard('zset'));
$this->redis->zrem('zset', 'a');
$this->assertEquals(count($zset) - 1, $this->redis->zcard('zset'));
@@ -1615,13 +1615,13 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->assertEquals(2, $this->redis->zremrangebyscore('zset', -10, 0));
$this->assertEquals(
array('c', 'd', 'e', 'f'),
array('c', 'd', 'e', 'f'),
$this->redis->zrange('zset', 0, -1)
);
$this->assertEquals(1, $this->redis->zremrangebyscore('zset', 10, 10));
$this->assertEquals(
array('d', 'e', 'f'),
array('d', 'e', 'f'),
$this->redis->zrange('zset', 0, -1)
);
@@ -1679,32 +1679,32 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->assertEquals(3, $this->redis->zremrangebyrank('zseta', 0, 2));
$this->assertEquals(
array('d', 'e', 'f'),
array('d', 'e', 'f'),
$this->redis->zrange('zseta', 0, -1)
);
$this->assertEquals(1, $this->redis->zremrangebyrank('zseta', 0, 0));
$this->assertEquals(
array('e', 'f'),
array('e', 'f'),
$this->redis->zrange('zseta', 0, -1)
);
RC::zsetAddAndReturn($this->redis, 'zsetb', RC::getZSetArray());
$this->assertEquals(3, $this->redis->zremrangebyrank('zsetb', -3, -1));
$this->assertEquals(
array('a', 'b', 'c'),
array('a', 'b', 'c'),
$this->redis->zrange('zsetb', 0, -1)
);
$this->assertEquals(1, $this->redis->zremrangebyrank('zsetb', -1, -1));
$this->assertEquals(
array('a', 'b'),
array('a', 'b'),
$this->redis->zrange('zsetb', 0, -1)
);
$this->assertEquals(2, $this->redis->zremrangebyrank('zsetb', -2, 1));
$this->assertEquals(
array(),
array(),
$this->redis->zrange('zsetb', 0, -1)
);
$this->assertFalse($this->redis->exists('zsetb'));
@@ -1915,7 +1915,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
// with parameter ASC/DESC
$this->assertEquals(
array(100, 30, 10, 3, 2, 1),
array(100, 30, 10, 3, 2, 1),
$this->redis->sort('unordered', array(
'sort' => 'desc'
))
@@ -1923,13 +1923,13 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
// with parameter LIMIT
$this->assertEquals(
array(1, 2, 3),
array(1, 2, 3),
$this->redis->sort('unordered', array(
'limit' => array(0, 3)
))
);
$this->assertEquals(
array(10, 30),
array(10, 30),
$this->redis->sort('unordered', array(
'limit' => array(3, 2)
))
@@ -1937,7 +1937,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
// with parameter ALPHA
$this->assertEquals(
array(1, 10, 100, 2, 3, 30),
array(1, 10, 100, 2, 3, 30),
$this->redis->sort('unordered', array(
'alpha' => true
))
@@ -1945,17 +1945,17 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
// with combined parameters
$this->assertEquals(
array(30, 10, 3, 2),
array(30, 10, 3, 2),
$this->redis->sort('unordered', array(
'alpha' => false,
'sort' => 'desc',
'alpha' => false,
'sort' => 'desc',
'limit' => array(1, 4)
))
);
// with parameter ALPHA
$this->assertEquals(
array(1, 10, 100, 2, 3, 30),
array(1, 10, 100, 2, 3, 30),
$this->redis->sort('unordered', array(
'alpha' => true
))
@@ -1963,7 +1963,7 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
// with parameter STORE
$this->assertEquals(
count($unorderedList),
count($unorderedList),
$this->redis->sort('unordered', array(
'store' => 'ordered'
))
@@ -1976,12 +1976,12 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->redis->rpush('uids', 1002);
$this->redis->rpush('uids', 1000);
$sortget = array(
'uid:1000' => 'foo', 'uid:1001' => 'bar',
'uid:1000' => 'foo', 'uid:1001' => 'bar',
'uid:1002' => 'hoge', 'uid:1003' => 'piyo'
);
$this->redis->mset($sortget);
$this->assertEquals(
array_values($sortget),
array_values($sortget),
$this->redis->sort('uids', array('get' => 'uid:*'))
);