From e851aaa21dbc29bae4a04bb3b54b628bf0fdb661 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Tue, 10 May 2016 14:55:30 +0200 Subject: [PATCH] Automatically assign aliases to slave connections. --- examples/replication_sentinel.php | 2 +- src/Connection/Aggregate/SentinelReplication.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/replication_sentinel.php b/examples/replication_sentinel.php index 1a737b17..11334070 100644 --- a/examples/replication_sentinel.php +++ b/examples/replication_sentinel.php @@ -54,7 +54,7 @@ $current = $client->getConnection()->getCurrent()->getParameters(); echo "We fetched 'foo' from {$current->alias} and its value is '$bar'.", PHP_EOL; /* OUTPUT: -Does 'foo' exist on slave? yes. +Does 'foo' exist on slave-127.0.0.1:6381? yes. Now 'foo' has been set to 'bar' on master! We fetched 'foo' from master and its value is 'bar'. */ diff --git a/src/Connection/Aggregate/SentinelReplication.php b/src/Connection/Aggregate/SentinelReplication.php index ff744c82..218bd5ef 100644 --- a/src/Connection/Aggregate/SentinelReplication.php +++ b/src/Connection/Aggregate/SentinelReplication.php @@ -240,6 +240,7 @@ class SentinelReplication extends MasterSlaveReplication $slaves[] = array( 'host' => $slave[3], 'port' => $slave[5], + 'alias' => "slave-$slave[3]:$slave[5]", ); }