Separate id and alias in predis cluster (client-side sharding).

This change does not affect distribution but simply separates the two
concepts of connection ID (ip:port pair) and alias (value set via the
"alias" connection parameter), the method getConnectionByAlias() has
been added to reflect this change.

The method getConnectionBySlot() has also been added.
This commit is contained in:
Daniele Alessandri
2016-06-18 16:59:48 +02:00
parent 0a7ddf7bba
commit 67c0fb8eb1
5 changed files with 123 additions and 88 deletions
+2 -2
View File
@@ -690,7 +690,7 @@ class ClientTest extends PredisTestCase
$nodes = array('tcp://host1?alias=node01', 'tcp://host2?alias=node02');
$client = $this->getMock('Predis\Client', array('dummy'), array($nodes, array('cluster' => 'predis')), 'SubclassedClient');
$this->assertInstanceOf('SubclassedClient', $client->getClientBy('id', 'node02'));
$this->assertInstanceOf('SubclassedClient', $client->getClientBy('alias', 'node02'));
}
/**
@@ -715,7 +715,7 @@ class ClientTest extends PredisTestCase
}))
->will($this->returnValue('value'));
$this->assertSame('value', $client->getClientBy('id', 'node02', $callable));
$this->assertSame('value', $client->getClientBy('alias', 'node02', $callable));
}
/**