jenkins-bot has submitted this change and it was merged.

Change subject: MessageCache: Use checkKeys for large messages
......................................................................


MessageCache: Use checkKeys for large messages

Also make use of the cache set options and use
Revision::newKnownCurrent() to avoid excessive
revision table queries during miss periods.

Bug: T144952
Change-Id: Ic1c649478b0f87420052d8c99b2962920f8b5c96
---
M includes/cache/MessageCache.php
1 file changed, 29 insertions(+), 10 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  AndyRussG: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php
index 6834ac0..ca6e28d 100644
--- a/includes/cache/MessageCache.php
+++ b/includes/cache/MessageCache.php
@@ -946,28 +946,47 @@
                        return false;
                }
 
-               # Try the individual message cache
+               // Try the individual message cache
                $titleKey = wfMemcKey( 'messages', 'individual', $title );
-               $entry = $this->wanCache->get( $titleKey );
+
+               $curTTL = null;
+               $entry = $this->wanCache->get(
+                       $titleKey,
+                       $curTTL,
+                       [ wfMemcKey( 'messages', $code ) ]
+               );
+               $entry = ( $curTTL >= 0 ) ? $entry : false;
+
                if ( $entry ) {
                        if ( substr( $entry, 0, 1 ) === ' ' ) {
                                $this->mCache[$code][$title] = $entry;
-
-                               // The message exists, so make sure a string
-                               // is returned.
+                               // The message exists, so make sure a string is 
returned
                                return (string)substr( $entry, 1 );
                        } elseif ( $entry === '!NONEXISTENT' ) {
                                $this->mCache[$code][$title] = '!NONEXISTENT';
 
                                return false;
                        } else {
-                               # Corrupt/obsolete entry, delete it
+                               // Corrupt/obsolete entry, delete it
                                $this->wanCache->delete( $titleKey );
                        }
                }
 
-               # Try loading it from the database
-               $revision = Revision::newFromTitle( Title::makeTitle( 
NS_MEDIAWIKI, $title ) );
+               // Try loading it from the database
+               $dbr = wfGetDB( DB_REPLICA );
+               $cacheOpts = Database::getCacheSetOptions( $dbr );
+               // Use newKnownCurrent() to avoid querying revision/user tables
+               $titleObj = Title::makeTitle( NS_MEDIAWIKI, $title );
+               if ( $titleObj->getLatestRevID() ) {
+                       $revision = Revision::newKnownCurrent(
+                               $dbr,
+                               $titleObj->getArticleID(),
+                               $titleObj->getLatestRevID()
+                       );
+               } else {
+                       $revision = false;
+               }
+
                if ( $revision ) {
                        $content = $revision->getContent();
                        if ( !$content ) {
@@ -994,7 +1013,7 @@
                                        $message = false; // negative caching
                                } else {
                                        $this->mCache[$code][$title] = ' ' . 
$message;
-                                       $this->wanCache->set( $titleKey, ' ' . 
$message, $this->mExpiry );
+                                       $this->wanCache->set( $titleKey, ' ' . 
$message, $this->mExpiry, $cacheOpts );
                                }
                        }
                } else {
@@ -1003,7 +1022,7 @@
 
                if ( $message === false ) { // negative caching
                        $this->mCache[$code][$title] = '!NONEXISTENT';
-                       $this->wanCache->set( $titleKey, '!NONEXISTENT', 
$this->mExpiry );
+                       $this->wanCache->set( $titleKey, '!NONEXISTENT', 
$this->mExpiry, $cacheOpts );
                }
 
                return $message;

-- 
To view, visit https://gerrit.wikimedia.org/r/316383
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1c649478b0f87420052d8c99b2962920f8b5c96
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: AndyRussG <andrew.green...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com>
Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to