MediaWiki  master
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 (ILoadBalancer $loadBalancer, $domain=false, array $groups=[])
 
 getReadConnection (array $groups=null)
 Returns a database connection for reading. More...
 
 getReadConnectionRef (array $groups=null)
 Returns a database connection ref for reading. More...
 
 getWriteConnection ()
 Returns a connection to the master DB, for updating. More...
 
 getWriteConnectionRef ()
 Returns a connection ref to the master DB, for updating. More...
 
 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
Author
Daniel Kinzler
Addshore

Definition at line 45 of file SessionConsistentConnectionManager.php.

Member Function Documentation

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

Definition at line 69 of file SessionConsistentConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups.

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

Definition at line 94 of file SessionConsistentConnectionManager.php.

References Wikimedia\Rdbms\ConnectionManager\$groups.

Wikimedia\Rdbms\SessionConsistentConnectionManager::getWriteConnection ( )
Wikimedia\Rdbms\SessionConsistentConnectionManager::getWriteConnectionRef ( )
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 58 of file SessionConsistentConnectionManager.php.

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

Member Data Documentation

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

Definition at line 50 of file SessionConsistentConnectionManager.php.


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