فهرست منبع

Automatically assign aliases to slave connections.

Daniele Alessandri 9 سال پیش
والد
کامیت
e851aaa21d
2فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  1. 1 1
      examples/replication_sentinel.php
  2. 1 0
      src/Connection/Aggregate/SentinelReplication.php

+ 1 - 1
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;
 echo "We fetched 'foo' from {$current->alias} and its value is '$bar'.", PHP_EOL;
 
 
 /* OUTPUT:
 /* 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!
 Now 'foo' has been set to 'bar' on master!
 We fetched 'foo' from master and its value is 'bar'.
 We fetched 'foo' from master and its value is 'bar'.
 */
 */

+ 1 - 0
src/Connection/Aggregate/SentinelReplication.php

@@ -240,6 +240,7 @@ class SentinelReplication extends MasterSlaveReplication
             $slaves[] = array(
             $slaves[] = array(
                 'host' => $slave[3],
                 'host' => $slave[3],
                 'port' => $slave[5],
                 'port' => $slave[5],
+                'alias' => "slave-$slave[3]:$slave[5]",
             );
             );
         }
         }