Implement "crc16" client option for redis-cluster.

By default Predis chooses automatically which hash generator to use:
if a suitable version of ext-phpiredis is loaded (that is, a version
that implements the phpiredis_utils_crc16() function) it uses the new
Predis\Cluster\Hash\PhpiredisCRC16 generator, otherwise it falls back
to the usual pure-PHP Predis\Cluster\Hash\CRC16 generator.
This commit is contained in:
Daniele Alessandri
2016-06-13 22:47:24 +02:00
parent 509a330bca
commit e38df19fac
5 changed files with 221 additions and 2 deletions
@@ -102,12 +102,19 @@ class ClusterTest extends PredisTestCase
$options = $this->getMock('Predis\Configuration\OptionsInterface');
$options
->expects($this->once())
->expects($this->at(0))
->method('__get')
->with('connections')
->will($this->returnValue(
$this->getMock('Predis\Connection\FactoryInterface')
));
$options
->expects($this->at(1))
->method('__get')
->with('crc16')
->will($this->returnValue(
$this->getMock('Predis\Cluster\Hash\HashGeneratorInterface')
));
$this->assertInstanceOf('Closure', $initializer = $option->filter($options, 'redis'));
$this->assertInstanceOf('Predis\Connection\Cluster\RedisCluster', $initializer($parameters = array()));