Predis\CommunicationException::shouldResetConnection PHP Method

shouldResetConnection() public method

Indicates if the receiver should reset the underlying connection.
public shouldResetConnection ( ) : boolean
return boolean
    public function shouldResetConnection()
    {
        return true;
    }

Usage Example

 /**
  * Offers a generic and reusable method to handle exceptions generated by
  * a connection object.
  *
  * @param CommunicationException $exception Exception.
  */
 public static function handle(CommunicationException $exception)
 {
     if ($exception->shouldResetConnection()) {
         $connection = $exception->getConnection();
         if ($connection->isConnected()) {
             $connection->disconnect();
         }
     }
     throw $exception;
 }