Merge "objectcache: rename getDB() to getConnection() in SqlBagOStuff"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 24 Aug 2019 20:57:17 +0000 (20:57 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 24 Aug 2019 20:57:17 +0000 (20:57 +0000)
includes/objectcache/SqlBagOStuff.php

index b0db53b..db4838f 100644 (file)
@@ -170,7 +170,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
         * @return IMaintainableDatabase
         * @throws MWException
         */
-       private function getDB( $shardIndex ) {
+       private function getConnection( $shardIndex ) {
                if ( $shardIndex >= $this->numServerShards ) {
                        throw new MWException( __METHOD__ . ": Invalid server index \"$shardIndex\"" );
                }
@@ -291,7 +291,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                $dataRows = [];
                foreach ( $keysByTable as $shardIndex => $serverKeys ) {
                        try {
-                               $db = $this->getDB( $shardIndex );
+                               $db = $this->getConnection( $shardIndex );
                                foreach ( $serverKeys as $tableName => $tableKeys ) {
                                        $res = $db->select( $tableName,
                                                [ 'keyname', 'value', 'exptime' ],
@@ -322,7 +322,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                                $this->debug( "get: retrieved data; expiry time is " . $row->exptime );
                                $db = null; // in case of connection failure
                                try {
-                                       $db = $this->getDB( $row->shardIndex );
+                                       $db = $this->getConnection( $row->shardIndex );
                                        if ( $this->isExpired( $db, $row->exptime ) ) { // MISS
                                                $this->debug( "get: key has expired" );
                                        } else { // HIT
@@ -365,7 +365,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                foreach ( $keysByTable as $shardIndex => $serverKeys ) {
                        $db = null; // in case of connection failure
                        try {
-                               $db = $this->getDB( $shardIndex );
+                               $db = $this->getConnection( $shardIndex );
                                $this->occasionallyGarbageCollect( $db ); // expire old entries if any
                                $dbExpiry = $exptime ? $db->timestamp( $exptime ) : $this->getMaxDateTime( $db );
                        } catch ( DBError $e ) {
@@ -480,7 +480,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                $silenceScope = $this->silenceTransactionProfiler();
                $db = null; // in case of connection failure
                try {
-                       $db = $this->getDB( $shardIndex );
+                       $db = $this->getConnection( $shardIndex );
                        // (T26425) use a replace if the db supports it instead of
                        // delete/insert to avoid clashes with conflicting keynames
                        $db->update(
@@ -534,7 +534,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                $silenceScope = $this->silenceTransactionProfiler();
                $db = null; // in case of connection failure
                try {
-                       $db = $this->getDB( $shardIndex );
+                       $db = $this->getConnection( $shardIndex );
                        $encTimestamp = $db->addQuotes( $db->timestamp() );
                        $db->update(
                                $tableName,
@@ -652,7 +652,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                foreach ( $shardIndexes as $numServersDone => $shardIndex ) {
                        $db = null; // in case of connection failure
                        try {
-                               $db = $this->getDB( $shardIndex );
+                               $db = $this->getConnection( $shardIndex );
                                $this->deleteServerObjectsExpiringBefore(
                                        $db,
                                        $timestamp,
@@ -757,7 +757,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                for ( $shardIndex = 0; $shardIndex < $this->numServerShards; $shardIndex++ ) {
                        $db = null; // in case of connection failure
                        try {
-                               $db = $this->getDB( $shardIndex );
+                               $db = $this->getConnection( $shardIndex );
                                for ( $i = 0; $i < $this->numTableShards; $i++ ) {
                                        $db->delete( $this->getTableNameByShard( $i ), '*', __METHOD__ );
                                }
@@ -784,7 +784,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
 
                $db = null; // in case of connection failure
                try {
-                       $db = $this->getDB( $shardIndex );
+                       $db = $this->getConnection( $shardIndex );
                        $ok = $db->lock( $key, __METHOD__, $timeout );
                        if ( $ok ) {
                                $this->locks[$key] = [ 'class' => $rclass, 'depth' => 1 ];
@@ -816,7 +816,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
 
                        $db = null; // in case of connection failure
                        try {
-                               $db = $this->getDB( $shardIndex );
+                               $db = $this->getConnection( $shardIndex );
                                $ok = $db->unlock( $key, __METHOD__ );
                                if ( !$ok ) {
                                        $this->logger->warning(
@@ -952,7 +952,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
         */
        public function createTables() {
                for ( $shardIndex = 0; $shardIndex < $this->numServerShards; $shardIndex++ ) {
-                       $db = $this->getDB( $shardIndex );
+                       $db = $this->getConnection( $shardIndex );
                        if ( $db->getType() !== 'mysql' ) {
                                throw new MWException( __METHOD__ . ' is not supported on this DB server' );
                        }