Compare commits

...

12 Commits

Author SHA1 Message Date
Daniele Alessandri 7a170b3d81 Update CHANGELOG and bump VERSION. 2015-01-02 13:51:34 +01:00
Daniele Alessandri 17e7bce22e Bump year in LICENSE.
[ci skip]
2015-01-02 13:45:19 +01:00
Daniele Alessandri 7a5d6bac3e Update CHANGELOG.
[ci skip]
2015-01-02 13:42:50 +01:00
Daniele Alessandri 9d6c031ead Merge remote-tracking branch 'srhnsn/v1.0' into v1.0 2015-01-02 13:33:10 +01:00
Daniele Alessandri 692718afb4 Merge remote-tracking branch 'blocktrail/hhvm-pubsub-blockingread-test-v1.0' into v1.0 2015-01-02 13:00:25 +01:00
Daniele Alessandri 0776377412 Temporarily allow failures for HHVM on Travis-CI.
[ci skip]
2015-01-02 12:56:48 +01:00
Daniele Alessandri e4b0512d42 No need to access a private field used by PHPUnit.
Fixes #207.
2015-01-02 12:20:00 +01:00
Daniele Alessandri 75ca2f8111 Add minimum required Redis version for BITPOS integration tests. 2015-01-02 12:14:05 +01:00
Daniele Alessandri 37b1c88115 Apply minor CS fixes and trim spurious spaces. 2015-01-02 12:13:58 +01:00
Daniele Alessandri a4e6130568 Merge remote-tracking branch 'nicchap/v1.0' into v1.0 2015-01-02 11:58:30 +01:00
Ruben de Vries f3748e45ef added (failing on HHVM) test for pubsub with read_write_timeout=-1 2014-12-19 11:40:59 +01:00
Serhan Şen beb6c28c65 Apply read_write_timeout to Unix socket connections. 2014-12-16 20:40:13 +01:00
12 changed files with 107 additions and 11 deletions
+1
View File
@@ -20,5 +20,6 @@ script:
- vendor/bin/phpunit -c phpunit.xml.travisci
matrix:
allow_failures:
- php: hhvm
- php: hhvm-nightly
fast_finish: true
+6 -1
View File
@@ -1,6 +1,11 @@
v1.0.1 (2014-xx-xx)
v1.0.1 (2015-01-02)
================================================================================
- Added `BITPOS` to the server profile for Redis 2.8.
- Connection timeout for read/write operations can now be set for UNIX sockets
where the underlying connection uses PHP's stream.
- __FIX__: broken values returned by `Predis\Collection\Iterator\SortedSetKey`
when iterating sorted set containing integer members (ISSUE #216).
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2009-2014 Daniele Alessandri
Copyright (c) 2009-2015 Daniele Alessandri
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
+1 -1
View File
@@ -1 +1 @@
1.0.1-dev
1.0.1
+1 -1
View File
@@ -11,7 +11,7 @@ desc = "Flexible and feature-complete PHP client library for Redis"
homepage = "http://github.com/nrk/predis"
license = "MIT"
version = "1.0.1"
stability = "devel"
stability = "stable"
channel = "pear.nrk.io"
author = "Daniele Alessandri \"nrk\" <suppakilla@gmail.com>"
+1 -1
View File
@@ -42,7 +42,7 @@ use Predis\Transaction\MultiExec as MultiExecTransaction;
*/
class Client implements ClientInterface
{
const VERSION = '1.0.1-dev';
const VERSION = '1.0.1';
protected $connection;
protected $options;
+8
View File
@@ -123,6 +123,14 @@ class StreamConnection extends AbstractConnection
$this->onConnectionError(trim($errstr), $errno);
}
if (isset($parameters->read_write_timeout)) {
$rwtimeout = (float) $parameters->read_write_timeout;
$rwtimeout = $rwtimeout > 0 ? $rwtimeout : -1;
$timeoutSeconds = floor($rwtimeout);
$timeoutUSeconds = ($rwtimeout - $timeoutSeconds) * 1000000;
stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds);
}
return $resource;
}
+1 -1
View File
@@ -234,7 +234,7 @@ class RedisVersion280 extends RedisProfile
/* commands operating on the key space */
'SCAN' => 'Predis\Command\KeyScan',
/* commands operating on string values */
'BITPOS' => 'Predis\Command\StringBitPos',
+1 -1
View File
@@ -234,7 +234,7 @@ class RedisVersion300 extends RedisProfile
/* commands operating on the key space */
'SCAN' => 'Predis\Command\KeyScan',
/* commands operating on string values */
'BITPOS' => 'Predis\Command\StringBitPos',
+4 -3
View File
@@ -19,6 +19,7 @@ use Predis\Profile;
*/
abstract class PredisTestCase extends \PHPUnit_Framework_TestCase
{
protected $predisRequirements = array();
protected $redisServerVersion = null;
/**
@@ -263,7 +264,7 @@ abstract class PredisTestCase extends \PHPUnit_Framework_TestCase
!empty($annotations['method']['requiresRedisVersion']) &&
in_array('connected', $annotations['method']['group'])
) {
$this->required['requiresRedisVersion'] = $annotations['method']['requiresRedisVersion'][0];
$this->predisRequirements['requiresRedisVersion'] = $annotations['method']['requiresRedisVersion'][0];
}
}
@@ -272,12 +273,12 @@ abstract class PredisTestCase extends \PHPUnit_Framework_TestCase
*/
protected function checkRequiredRedisVersion()
{
if (!isset($this->required['requiresRedisVersion'])) {
if (!isset($this->predisRequirements['requiresRedisVersion'])) {
return;
}
$srvVersion = $this->getRedisServerVersion();
$expectation = explode(' ', $this->required['requiresRedisVersion'], 2);
$expectation = explode(' ', $this->predisRequirements['requiresRedisVersion'], 2);
if (count($expectation) === 1) {
$expOperator = '>=';
+15 -1
View File
@@ -8,6 +8,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Command;
/**
* @group commands
* @group realm-string
@@ -21,6 +22,7 @@ class StringBitPosTest extends PredisCommandTestCase
{
return 'Predis\Command\StringBitPos';
}
/**
* {@inheritdoc}
*/
@@ -28,6 +30,7 @@ class StringBitPosTest extends PredisCommandTestCase
{
return 'BITPOS';
}
/**
* @group disconnected
*/
@@ -35,10 +38,13 @@ class StringBitPosTest extends PredisCommandTestCase
{
$arguments = array('key', 0, 1, 10);
$expected = array('key', 0, 1, 10);
$command = $this->getCommand();
$command->setArguments($arguments);
$this->assertSame($expected, $command->getArguments());
}
/**
* @group disconnected
*/
@@ -47,25 +53,33 @@ class StringBitPosTest extends PredisCommandTestCase
$raw = 10;
$expected = 10;
$command = $this->getCommand();
$this->assertSame($expected, $command->parseResponse($raw));
}
/**
* @group connected
* @requiresRedisVersion >= 2.8.7
*/
public function testReturnsBitPosition()
{
$redis = $this->getClient();
$redis->setbit('key', 10, 0);
$this->assertSame(0, $redis->bitpos('key', 0), 'Get position of first bit set to 0 - full range');
$this->assertSame(-1, $redis->bitpos('key', 1), 'Get position of first bit set to 1 - full range');
$this->assertSame(-1, $redis->bitpos('key', 1, 5, 10), 'Get position of first bit set to 1 - specific range');
$redis->setbit('key', 5, 1);
$this->assertSame(0, $redis->bitpos('key', 0), 'Get position of first bit set to 0 - full range');
$this->assertSame(5, $redis->bitpos('key', 1), 'Get position of first bit set to 1 - full range');
$this->assertSame(-1, $redis->bitpos('key', 1, 5, 10), 'Get position of first bit set to 1 - specific range');
$this->assertSame(-1, $redis->bitpos('key', 1, 5, 10), 'Get position of first bit set to 1 - specific range');
}
/**
* @group connected
* @requiresRedisVersion >= 2.8.7
* @expectedException \Predis\Response\ServerException
* @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
+67
View File
@@ -340,4 +340,71 @@ class ConsumerTest extends PredisTestCase
$this->assertFalse($pubsub->valid());
$this->assertEquals('ECHO', $consumer->echo('ECHO'));
}
/**
* @group connected
*/
public function testPubSubAgainstRedisServerBlocking()
{
$parameters = array(
'host' => REDIS_SERVER_HOST,
'port' => REDIS_SERVER_PORT,
'database' => REDIS_SERVER_DBNUM,
'read_write_timeout' => -1, // -1 to set blocking reads
);
$options = array('profile' => REDIS_SERVER_VERSION);
// create consumer before forking so the child can disconnect it
$consumer = new Client($parameters, $options);
$consumer->connect();
/*
* fork
* parent: consumer
* child: producer
*/
if ($childPID = pcntl_fork()) {
$messages = array();
$pubsub = new PubSubConsumer($consumer);
$pubsub->subscribe('channel:foo');
foreach ($pubsub as $message) {
if ($message->kind !== 'message') {
continue;
}
$messages[] = ($payload = $message->payload);
if ($payload === 'QUIT') {
$pubsub->stop();
}
}
$this->assertSame(array('message1', 'message2', 'QUIT'), $messages);
$this->assertFalse($pubsub->valid());
$this->assertEquals('ECHO', $consumer->echo('ECHO'));
// kill the child
posix_kill($childPID, SIGKILL);
} else {
// create producer, read_write_timeout = 2 because it doesn't do blocking reads anyway
$producer = new Client(array_replace($parameters, array('read_write_timeout' => 2)), $options);
$producer->connect();
$producer->publish('channel:foo', 'message1');
$producer->publish('channel:foo', 'message2');
$producer->publish('channel:foo', 'QUIT');
// sleep, giving the consumer a chance to respond to the QUIT message
sleep(1);
// disconnect the consumer because otherwise it could remain stuck in blocking read
// if it failed to respond to the QUIT message
$consumer->disconnect();
// exit child
exit(0);
}
}
}