class ConnectionLease implements NonCopyableContext

Keep a caller's logical connection stable while its physical sessions are pooled.

PDO connections receive the borrowed handles directly. Drivers implementing LeasableConnection build their own logical connection and ask the lease for the physical connection whenever an operation needs it.

Properties

Connection $connection
protected PooledConnection|null $pooledConnection
protected bool $ended
protected null|PDO $pdoResolver
protected null|PDO $readPdoResolver

Methods

__construct(DatabasePool $pool, PooledConnection $pooledConnection, ConnectionFactory $factory, Connection $physicalConnection)

Create a logical connection from its initially borrowed physical session.

heldPooledConnection()

Get the held pooled connection, borrowing one when the session was returned early.

PDO
resolvePdo(bool $read = false)

Resolve a physical handle and publish its generation to the logical owner.

resolvePhysicalConnection()

Resolve a driver's physical connection and publish its generation to the logical owner.

reconnect()

Replace the held physical session and reconnect the logical owner.

void
releaseIfIdle()

Release the held session when no operation requires it.

void
release()

End logical ownership and release the currently held physical session.

void
discard()

End logical ownership and discard the currently held physical session.

bool
hasEnded()

Determine whether logical ownership has ended.

void
detach()

Remove references to a session before its slot becomes available again.

void
discardAfterFailure(Throwable $exception)

Discard a failed acquisition without replacing its exception.

Details

at line 42
__construct(DatabasePool $pool, PooledConnection $pooledConnection, ConnectionFactory $factory, Connection $physicalConnection)

Create a logical connection from its initially borrowed physical session.

Parameters

DatabasePool $pool
PooledConnection $pooledConnection
ConnectionFactory $factory
Connection $physicalConnection

at line 76
protected PooledConnection heldPooledConnection()

Get the held pooled connection, borrowing one when the session was returned early.

Return Value

PooledConnection

at line 95
protected PDO resolvePdo(bool $read = false)

Resolve a physical handle and publish its generation to the logical owner.

Parameters

bool $read

Return Value

PDO

at line 128
protected Connection&LeasableConnection resolvePhysicalConnection()

Resolve a driver's physical connection and publish its generation to the logical owner.

at line 151
Connection reconnect()

Replace the held physical session and reconnect the logical owner.

Return Value

Connection

at line 172
void releaseIfIdle()

Release the held session when no operation requires it.

Return Value

void

at line 187
void release()

End logical ownership and release the currently held physical session.

Return Value

void

at line 196
void discard()

End logical ownership and discard the currently held physical session.

Return Value

void

at line 205
bool hasEnded()

Determine whether logical ownership has ended.

Return Value

bool

at line 213
void detach()

Remove references to a session before its slot becomes available again.

Return Value

void

at line 228
protected void discardAfterFailure(Throwable $exception)

Discard a failed acquisition without replacing its exception.

Parameters

Throwable $exception

Return Value

void