File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -210,13 +210,16 @@ public function __construct($options = array())
210210 if ( ! empty ($ options ['load_from_slaves ' ])) {
211211 $ slaves = $ sentinel ->getSlaveClients ($ sentinelMaster );
212212 if ($ slaves ) {
213+ if ($ options ['load_from_slaves ' ] == 2 ) {
214+ array_push ($ slaves , $ this ->_redis ); // Also send reads to the master
215+ }
213216 if ($ slaveSelect ) {
214217 $ slave = $ slaveSelect ($ slaves , $ this ->_redis );
215218 } else {
216219 $ slaveKey = array_rand ($ slaves , 1 );
217220 $ slave = $ slaves [$ slaveKey ]; /* @var $slave Credis_Client */
218221 }
219- if ($ slave instanceof Credis_Client) {
222+ if ($ slave instanceof Credis_Client && $ slave != $ this -> _redis ) {
220223 try {
221224 $ this ->_applyClientOptions ($ slave , TRUE );
222225 $ this ->_slave = $ slave ;
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ You may achieve high availability and load balancing using [Redis Sentinel](http
8282specified should be a comma-separated list of Sentinel servers and the ` sentinel_master ` option should be specified
8383to indicate the name of the sentinel master set (e.g. 'mymaster'). If using ` sentinel_master ` you may also specify
8484` load_from_slaves ` in which case a random slave will be chosen for performing reads in order to load balance across multiple Redis instances.
85+ Using the value '1' indicates to only load from slaves and '2' to include the master in the random read slave selection.
8586
8687Example configuration:
8788
You can’t perform that action at this time.
0 commit comments