MediaWiki REL1_40
Wikimedia\Rdbms\SessionConsistentConnectionManager Class Reference

Database connection manager. More...

Inherits Wikimedia\Rdbms\ConnectionManager.

Collaboration diagram for Wikimedia\Rdbms\SessionConsistentConnectionManager:

Public Member Functions

 getReadConnection (?array $groups=null, int $flags=0)
 
 getReadConnectionRef (array $groups=null)
 
 getWriteConnection (int $flags=0)
 
 getWriteConnectionRef ()
 
 prepareForUpdates ()
 Forces all future calls to getReadConnection() to return a write connection.
 
- Public Member Functions inherited from Wikimedia\Rdbms\ConnectionManager
 __construct (ILoadBalancer $loadBalancer, $domain=false, array $groups=[])
 
 getLazyReadConnectionRef (array $groups=null)
 Returns a lazy-connecting database connection ref for reading.
 
 getLazyWriteConnectionRef ()
 Returns a lazy-connecting database connection ref for updating.
 
 releaseConnection (IDatabase $db)
 

Detailed Description

Database connection manager.

This manages access to primary and replica databases. It also manages state that indicates whether the replica databases are possibly outdated after a write operation, and thus the primary database should be used for subsequent read operations.

Note
: Services that access overlapping sets of database tables, or interact with logically related sets of data in the database, should share a SessionConsistentConnectionManager. Services accessing unrelated sets of information may prefer to not share a SessionConsistentConnectionManager, so they can still perform read operations against replica databases after a (unrelated, per the assumption) write operation to the primary database. Generally, sharing a SessionConsistentConnectionManager improves consistency (by avoiding race conditions due to replication lag), but can reduce performance (by directing more read operations to the primary database server).
Since
1.29
Author
Daniel Kinzler
Addshore

Definition at line 43 of file SessionConsistentConnectionManager.php.

Member Function Documentation

◆ getReadConnection()

Wikimedia\Rdbms\SessionConsistentConnectionManager::getReadConnection ( ?array $groups = null,
int $flags = 0 )
Since
1.29
1.37 Added optional $flags parameter
Parameters
string[] | null$groups
int$flags
Returns
IDatabase

Reimplemented from Wikimedia\Rdbms\ConnectionManager.

Definition at line 69 of file SessionConsistentConnectionManager.php.

◆ getReadConnectionRef()

Wikimedia\Rdbms\SessionConsistentConnectionManager::getReadConnectionRef ( array $groups = null)
Since
1.29
Parameters
string[] | null$groups
Returns
DBConnRef
Deprecated
since 1.40; Use getReadConnection()

Reimplemented from Wikimedia\Rdbms\ConnectionManager.

Definition at line 98 of file SessionConsistentConnectionManager.php.

◆ getWriteConnection()

Wikimedia\Rdbms\SessionConsistentConnectionManager::getWriteConnection ( int $flags = 0)
Since
1.29
1.37 Added optional $flags parameter
Parameters
int$flags
Returns
IDatabase

Reimplemented from Wikimedia\Rdbms\ConnectionManager.

Definition at line 85 of file SessionConsistentConnectionManager.php.

References Wikimedia\Rdbms\SessionConsistentConnectionManager\prepareForUpdates().

◆ getWriteConnectionRef()

Wikimedia\Rdbms\SessionConsistentConnectionManager::getWriteConnectionRef ( )
Since
1.29
Returns
DBConnRef
Deprecated
since 1.40; Use getWriteConnection()

Reimplemented from Wikimedia\Rdbms\ConnectionManager.

Definition at line 112 of file SessionConsistentConnectionManager.php.

References Wikimedia\Rdbms\SessionConsistentConnectionManager\prepareForUpdates().

◆ prepareForUpdates()

Wikimedia\Rdbms\SessionConsistentConnectionManager::prepareForUpdates ( )

Forces all future calls to getReadConnection() to return a write connection.

Use this before performing read operations that are critical for a future update.

Since
1.29

Definition at line 56 of file SessionConsistentConnectionManager.php.

Referenced by Wikimedia\Rdbms\SessionConsistentConnectionManager\getWriteConnection(), and Wikimedia\Rdbms\SessionConsistentConnectionManager\getWriteConnectionRef().


The documentation for this class was generated from the following file: