MediaWiki master
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)
 
 getWriteConnection (int $flags=0)
 
 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=[])
 

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
IReadableDatabase

Reimplemented from Wikimedia\Rdbms\ConnectionManager.

Definition at line 69 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().

◆ 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().


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