Class ReconnectStrategy
Makes sure the connection to the database is alive before authorizing the retry of an action.
Property Summary
- 
        $causes protected staticarrayThe list of error strings to match when looking for a disconnection error. 
- 
        $connection protectedCake\Database\ConnectionThe connection to check for validity 
Method Summary
- 
          __construct() publicCreates the ReconnectStrategy object by storing a reference to the passed connection. This reference will be used to automatically reconnect to the server in case of failure. 
- 
          reconnect() protectedTries to re-establish the connection to the server, if it is safe to do so 
- 
          shouldRetry() publicChecks whether or not the exception was caused by a lost connection, and returns true if it was able to successfully reconnect. 
Method Detail
__construct() ¶ public
__construct(Cake\Database\Connection $connection)Creates the ReconnectStrategy object by storing a reference to the passed connection. This reference will be used to automatically reconnect to the server in case of failure.
Parameters
- 
                Cake\Database\Connection$connection
- The connection to check 
reconnect() ¶ protected
reconnect(): boolTries to re-establish the connection to the server, if it is safe to do so
Returns
boolWhether or not the connection was re-established
shouldRetry() ¶ public
shouldRetry(Exception $exception, int $retryCount): boolChecks whether or not the exception was caused by a lost connection, and returns true if it was able to successfully reconnect.
Parameters
- 
                Exception$exception
- The exception to check for its message 
- 
                int$retryCount
- The number of times the action has been already called 
Returns
boolWhether or not it is OK to retry the action
