src/Connection/Aggregate/MasterSlaveReplication.php
private function retryCommandOnFailure(CommandInterface $command, $method)
    {
        RETRY_COMMAND: {
            try {
                $connection = $this->getConnection($command);
                $response = $connection->$method($command);

                if ($response instanceof ResponseErrorInterface && $response->getErrorType() === 'LOADING') {
                    throw new ConnectionException($connection, "Redis is loading the dataset in memory [$connection]");
                }
            } catch (ConnectionException $exception) {
                $connection = $exception->getConnection();
                $connection->disconnect();

                if ($connection === $this->master && !$this->autoDiscovery) {
                    // Throw immediately when master connection is failing, even
                    // when the command represents a read-only operation, unless
                    // automatic discovery has been enabled.
                    throw $exception;
                } else {
                    // Otherwise remove the failing slave and attempt to execute
                    // the command again on one of the remaining slaves...
                    $this->remove($connection);
                }

                // ... that is, unless we have no more connections to use.
                if (!$this->slaves && !$this->master) {
                    throw $exception;
                } elseif ($this->autoDiscovery) {
                    $this->discover();
                }

                goto RETRY_COMMAND;
            } catch (MissingMasterException $exception) {
                if ($this->autoDiscovery) {
                    $this->discover();
                } else {
                    throw $exception;
                }

                goto RETRY_COMMAND;
            }
        }

        return $response;
    }
private function retryCommandOnFailure(CommandInterface $command, $method)
    {
        RETRY_COMMAND: {
            try {
                $connection = $this->getConnection($command);
                $response = $connection->$method($command);

                if ($response instanceof ResponseErrorInterface && $response->getErrorType() === 'LOADING') {
                    throw new ConnectionException($connection, "Redis is loading the dataset in memory [$connection]");
                }
            } catch (ConnectionException $exception) {
                $connection = $exception->getConnection();
                $connection->disconnect();

                if ($connection === $this->master && !$this->autoDiscovery) {
                    // Throw immediately when master connection is failing, even
                    // when the command represents a read-only operation, unless
                    // automatic discovery has been enabled.
                    throw $exception;
                } else {
                    // Otherwise remove the failing slave and attempt to execute
                    // the command again on one of the remaining slaves...
                    $this->remove($connection);
                }

                // ... that is, unless we have no more connections to use.
                if (!$this->slaves && !$this->master) {
                    throw $exception;
                } elseif ($this->autoDiscovery) {
                    $this->discover();
                }

                goto RETRY_COMMAND;
            } catch (MissingMasterException $exception) {
                if ($this->autoDiscovery) {
                    $this->discover();
                } else {
                    throw $exception;
                }

                goto RETRY_COMMAND;
            }
        }

        return $response;
    }
private function retryCommandOnFailure ( CommandInterface $ command , $ method ) { RETRY_COMMAND : { try { $ connection = $ this -> getConnection ( $ command ) ; $ response = $ connection -> $ method ( $ command ) ; if ( $ response instanceof ResponseErrorInterface && $ response -> getErrorType ( ) === 'LOADING' ) { throw new ConnectionException ( $ connection , "Redis is loading the dataset in memory [$connection]" ) ; } } catch ( ConnectionException $ exception ) { $ connection = $ exception -> getConnection ( ) ; $ connection -> disconnect ( ) ; if ( $ connection === $ this -> master && ! $ this -> autoDiscovery ) { // Throw immediately when master connection is failing, even // when the command represents a read-only operation, unless // automatic discovery has been enabled. throw $ exception ; } else { // Otherwise remove the failing slave and attempt to execute // the command again on one of the remaining slaves... $ this -> remove ( $ connection ) ; } // ... that is, unless we have no more connections to use. if ( ! $ this -> slaves && ! $ this -> master ) { throw $ exception ; } elseif ( $ this -> autoDiscovery ) { $ this -> discover ( ) ; } goto RETRY_COMMAND ; } catch ( MissingMasterException $ exception ) { if ( $ this -> autoDiscovery ) { $ this -> discover ( ) ; } else { throw $ exception ; } goto RETRY_COMMAND ; } } return $ response ; }
Retries the execution of a command upon slave failure.

@param CommandInterface $command Command instance.
@param string           $method  Actual method.

@return mixed
Retries the execution of a command upon slave failure .