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

Change subject: Change getCacheSetOptions() callers to use "Database"
......................................................................


Change getCacheSetOptions() callers to use "Database"

* This is less verbose that DatabaseBase
* Also add a few WAN cache doc comments

Change-Id: I5b6de6d0ffa06753ea96c50b63db7dae796475dc
---
M includes/User.php
M includes/actions/InfoAction.php
M includes/changetags/ChangeTags.php
M includes/filerepo/LocalRepo.php
M includes/filerepo/file/LocalFile.php
M includes/interwiki/Interwiki.php
M includes/libs/objectcache/WANObjectCache.php
7 files changed, 17 insertions(+), 14 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/User.php b/includes/User.php
index 20b75bf..75649a7 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -458,7 +458,7 @@
                $data['mVersion'] = self::VERSION;
                $key = wfMemcKey( 'user', 'id', $this->mId );
 
-               $opts = DatabaseBase::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
+               $opts = Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
                ObjectCache::getMainWANInstance()->set( $key, $data, 3600, 
$opts );
        }
 
diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php
index 4e74ed3..78dd5fe 100644
--- a/includes/actions/InfoAction.php
+++ b/includes/actions/InfoAction.php
@@ -682,7 +682,7 @@
                                $dbr = wfGetDB( DB_SLAVE );
                                $dbrWatchlist = wfGetDB( DB_SLAVE, 'watchlist' 
);
 
-                               $setOpts += DatabaseBase::getCacheSetOptions( 
$dbr, $dbrWatchlist );
+                               $setOpts += Database::getCacheSetOptions( $dbr, 
$dbrWatchlist );
 
                                $result = array();
 
diff --git a/includes/changetags/ChangeTags.php 
b/includes/changetags/ChangeTags.php
index e1b9b27..5531245 100644
--- a/includes/changetags/ChangeTags.php
+++ b/includes/changetags/ChangeTags.php
@@ -1091,7 +1091,7 @@
                return ObjectCache::getMainWANInstance()->getWithSetCallback(
                        wfMemcKey( 'active-tags' ),
                        function ( $oldValue, &$ttl, array &$setOpts ) {
-                               $setOpts += DatabaseBase::getCacheSetOptions( 
wfGetDB( DB_SLAVE ) );
+                               $setOpts += Database::getCacheSetOptions( 
wfGetDB( DB_SLAVE ) );
 
                                // Ask extensions which tags they consider 
active
                                $extensionActive = array();
@@ -1135,7 +1135,7 @@
                        function ( $oldValue, &$ttl, array &$setOpts ) use ( 
$fname ) {
                                $dbr = wfGetDB( DB_SLAVE );
 
-                               $setOpts += DatabaseBase::getCacheSetOptions( 
$dbr );
+                               $setOpts += Database::getCacheSetOptions( $dbr 
);
 
                                $tags = $dbr->selectFieldValues( 'valid_tag', 
'vt_tag', array(), $fname );
 
@@ -1160,7 +1160,7 @@
                return ObjectCache::getMainWANInstance()->getWithSetCallback(
                        wfMemcKey( 'valid-tags-hook' ),
                        function ( $oldValue, &$ttl, array &$setOpts ) {
-                               $setOpts += DatabaseBase::getCacheSetOptions( 
wfGetDB( DB_SLAVE ) );
+                               $setOpts += Database::getCacheSetOptions( 
wfGetDB( DB_SLAVE ) );
 
                                $tags = array();
                                Hooks::run( 'ListDefinedTags', array( &$tags ) 
);
@@ -1221,7 +1221,7 @@
                        function ( $oldValue, &$ttl, array &$setOpts ) use ( 
$fname ) {
                                $dbr = wfGetDB( DB_SLAVE, 'vslow' );
 
-                               $setOpts += DatabaseBase::getCacheSetOptions( 
$dbr );
+                               $setOpts += Database::getCacheSetOptions( $dbr 
);
 
                                $res = $dbr->select(
                                        'change_tag',
diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php
index 389f081..02d859f 100644
--- a/includes/filerepo/LocalRepo.php
+++ b/includes/filerepo/LocalRepo.php
@@ -205,7 +205,7 @@
                        function ( $oldValue, &$ttl, array &$setOpts ) use ( 
$that, $title ) {
                                $dbr = $that->getSlaveDB(); // possibly remote 
DB
 
-                               $setOpts += DatabaseBase::getCacheSetOptions( 
$dbr );
+                               $setOpts += Database::getCacheSetOptions( $dbr 
);
 
                                if ( $title instanceof Title ) {
                                        $row = $dbr->selectRow(
diff --git a/includes/filerepo/file/LocalFile.php 
b/includes/filerepo/file/LocalFile.php
index d5179cb..50b9caf 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -309,7 +309,7 @@
 
                // Cache presence for 1 week and negatives for 1 day
                $ttl = $this->fileExists ? 86400 * 7 : 86400;
-               $opts = DatabaseBase::getCacheSetOptions( 
$this->repo->getSlaveDB() );
+               $opts = Database::getCacheSetOptions( $this->repo->getSlaveDB() 
);
                ObjectCache::getMainWANInstance()->set( $key, $cacheVal, $ttl, 
$opts );
        }
 
diff --git a/includes/interwiki/Interwiki.php b/includes/interwiki/Interwiki.php
index 89aeaae..7a49f9b 100644
--- a/includes/interwiki/Interwiki.php
+++ b/includes/interwiki/Interwiki.php
@@ -221,7 +221,7 @@
                        function ( $oldValue, &$ttl, array &$setOpts ) use ( 
$prefix ) {
                                $dbr = wfGetDB( DB_SLAVE );
 
-                               $setOpts += DatabaseBase::getCacheSetOptions( 
$dbr );
+                               $setOpts += Database::getCacheSetOptions( $dbr 
);
 
                                $row = $dbr->selectRow(
                                        'interwiki',
diff --git a/includes/libs/objectcache/WANObjectCache.php 
b/includes/libs/objectcache/WANObjectCache.php
index b1d3ec2..7e70e4b 100644
--- a/includes/libs/objectcache/WANObjectCache.php
+++ b/includes/libs/objectcache/WANObjectCache.php
@@ -269,10 +269,12 @@
         *   - d) T1 reads the row and calls set() due to a cache miss
         *   - e) Stale value is stuck in cache
         *
+        * Setting 'lag' helps avoids keys getting stuck in long-term stale 
states.
+        *
         * Example usage:
         * @code
         *     $dbr = wfGetDB( DB_SLAVE );
-        *     $setOpts = DatabaseBase::getCacheSetOptions( $dbr );
+        *     $setOpts = Database::getCacheSetOptions( $dbr );
         *     // Fetch the row from the DB
         *     $row = $dbr->selectRow( ... );
         *     $key = wfMemcKey( 'building', $buildingId );
@@ -505,6 +507,7 @@
         * can be set dynamically by altering $ttl in the callback (by 
reference).
         * The $setOpts array can be altered and is given to set() when called;
         * it is recommended to set the 'since' field to avoid race conditions.
+        * Setting 'lag' helps avoids keys getting stuck in long-term stale 
states.
         *
         * Usually, callbacks ignore the current value, but it can be used
         * to maintain "most recent X" values that come from time or sequence
@@ -529,7 +532,7 @@
         *         function ( $oldValue, &$ttl, array &$setOpts ) {
         *             $dbr = wfGetDB( DB_SLAVE );
         *             // Account for any snapshot/slave lag
-        *             $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+        *             $setOpts += Database::getCacheSetOptions( $dbr );
         *
         *             return $dbr->selectRow( ... );
         *        },
@@ -547,7 +550,7 @@
         *         function ( $oldValue, &$ttl, array &$setOpts ) {
         *             $dbr = wfGetDB( DB_SLAVE );
         *             // Account for any snapshot/slave lag
-        *             $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+        *             $setOpts += Database::getCacheSetOptions( $dbr );
         *
         *             return CatConfig::newFromRow( $dbr->selectRow( ... ) );
         *        },
@@ -570,7 +573,7 @@
         *             // Determine new value from the DB
         *             $dbr = wfGetDB( DB_SLAVE );
         *             // Account for any snapshot/slave lag
-        *             $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+        *             $setOpts += Database::getCacheSetOptions( $dbr );
         *
         *             return CatState::newFromResults( $dbr->select( ... ) );
         *        },
@@ -595,7 +598,7 @@
         *         function ( $oldValue, &$ttl, array &$setOpts ) {
         *             $dbr = wfGetDB( DB_SLAVE );
         *             // Account for any snapshot/slave lag
-        *             $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+        *             $setOpts += Database::getCacheSetOptions( $dbr );
         *
         *             // Start off with the last cached list
         *             $list = $oldValue ?: array();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5b6de6d0ffa06753ea96c50b63db7dae796475dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: TTO <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to