\Cake\Database\RetryReconnectStrategy

Makes sure the connection to the database is alive before authorizing the retry of an action.

Summary

Methods
Properties
Constants
__construct()
shouldRetry()
No public properties found
No constants found
reconnect()
$causes
$connection
N/A
No private methods found
No private properties found
N/A

Properties

$causes

$causes : array

The list of error strings to match when looking for a disconnection error.

This is a static variable to enable opcache to inline the values.

Type

array

Methods

__construct()

__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

shouldRetry()

shouldRetry(\Exception  $exception, integer  $retryCount) : boolean

Checks 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

integer $retryCount

The number of times the action has been already called

Returns

boolean —

Whether or not it is OK to retry the action

reconnect()

reconnect() : boolean

Tries to re-establish the connection to the server, if it is safe to do so

Returns

boolean —

Whether or not the connection was re-established