protected function getRandomSlave($fallbackToMaster = true)
    {
        $slaves = $this->client->getConnection()->getSlaves();

        if (count($slaves) > 0) {
            $slave = $slaves[rand(1, count($slaves)) - 1];

            return $this->client->getClientFor($slave->getParameters()->alias);
        }

        if ($fallbackToMaster) {
            return $this->getMaster();
        }

        throw new RuntimeException('No slave present on connection.');
    }
protected function getRandomSlave($fallbackToMaster = true)
    {
        $slaves = $this->client->getConnection()->getSlaves();

        if (count($slaves) > 0) {
            $slave = $slaves[rand(1, count($slaves)) - 1];

            return $this->client->getClientFor($slave->getParameters()->alias);
        }

        if ($fallbackToMaster) {
            return $this->getMaster();
        }

        throw new RuntimeException('No slave present on connection.');
    }
protected function getRandomSlave ( $ fallbackToMaster = true ) { $ slaves = $ this -> client -> getConnection ( ) -> getSlaves ( ) ; if ( count ( $ slaves ) > 0 ) { $ slave = $ slaves [ rand ( 1 , count ( $ slaves ) ) - 1 ] ; return $ this -> client -> getClientFor ( $ slave -> getParameters ( ) -> alias ) ; } if ( $ fallbackToMaster ) { return $ this -> getMaster ( ) ; } throw new RuntimeException ( 'No slave present on connection.' ) ; }
Get a Predis client instance for a random slave.

@param bool $fallbackToMaster If TRUE, return a client for the master
if the connection does not include any slaves.

@return Client The client instance for the selected slave.

@throws RuntimeException When the client cannot reach any replicas
(and the master if $fallbackToMaster is TRUE).
Get a Predis client instance for a random slave .