MediaWiki  1.29.1
Wikimedia\Rdbms\SessionConsistentConnectionManager Class Reference

Database connection manager. More...

Inheritance diagram for Wikimedia\Rdbms\SessionConsistentConnectionManager:
Collaboration diagram for Wikimedia\Rdbms\SessionConsistentConnectionManager:

Public Member Functions

 getReadConnection (array $groups=null)
 
 getReadConnectionRef (array $groups=null)
 
 getWriteConnection ()
 
 getWriteConnectionRef ()
 
 prepareForUpdates ()
 Forces all future calls to getReadConnection() to return a write connection. More...
 
- Public Member Functions inherited from Wikimedia\Rdbms\ConnectionManager
 __construct (LoadBalancer $loadBalancer, $domain=false, array $groups=[])
 
 releaseConnection (IDatabase $db)
 

Private Attributes

bool $forceWriteConnection = false
 

Detailed Description

Database connection manager.

This manages access to master and replica databases. It also manages state that indicates whether the replica databases are possibly outdated after a write operation, and thus the master 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 master 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 master database server).
Since
1.29
Note
GPL-2.0+
Author
Daniel Kinzler
Addshore

Definition at line 27 of file SessionConsistentConnectionManager.php.

Member Function Documentation

◆ getReadConnection()

Wikimedia\Rdbms\SessionConsistentConnectionManager::getReadConnection ( array  $groups = null)
Since
1.29
Parameters
string[] | null$groups
Returns
Database

Reimplemented from Wikimedia\Rdbms\ConnectionManager.

Definition at line 51 of file SessionConsistentConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups.

◆ getReadConnectionRef()

Wikimedia\Rdbms\SessionConsistentConnectionManager::getReadConnectionRef ( array  $groups = null)
Since
1.29
Parameters
string[] | null$groups
Returns
DBConnRef

Reimplemented from Wikimedia\Rdbms\ConnectionManager.

Definition at line 76 of file SessionConsistentConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups.

◆ getWriteConnection()

Wikimedia\Rdbms\SessionConsistentConnectionManager::getWriteConnection ( )

◆ getWriteConnectionRef()

Wikimedia\Rdbms\SessionConsistentConnectionManager::getWriteConnectionRef ( )

◆ 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 40 of file SessionConsistentConnectionManager.php.

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

Member Data Documentation

◆ $forceWriteConnection

bool Wikimedia\Rdbms\SessionConsistentConnectionManager::$forceWriteConnection = false
private

Definition at line 32 of file SessionConsistentConnectionManager.php.


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