objectcache: rename getDB() to getConnection() in SqlBagOStuff
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 9 Aug 2019 06:23:05 +0000 (23:23 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 24 Aug 2019 20:18:50 +0000 (13:18 -0700)
Change-Id: I7ec33e2622f5b418712d76bedcbb4be65376cf91

includes/objectcache/SqlBagOStuff.php

index a1820ab..fe27b78 100644 (file)
@@ -169,7 +169,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\"" );
                }
@@ -290,7 +290,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' ],
@@ -321,7 +321,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
@@ -364,7 +364,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 ) {
@@ -479,7 +479,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(
@@ -533,7 +533,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,
@@ -647,7 +647,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,
@@ -752,7 +752,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__ );
                                }
@@ -779,7 +779,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 ];
@@ -811,7 +811,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(
@@ -947,7 +947,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' );
                        }