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

Change subject: Convert SiteStatsUpdate to using getMainStashInstance()
......................................................................


Convert SiteStatsUpdate to using getMainStashInstance()

Also fixed various $wgMemc related comments

Change-Id: I20602b672f724c8df1e82bbe3c586cb899a54640
---
M includes/cache/CacheDependency.php
M includes/deferred/SiteStatsUpdate.php
M includes/jobqueue/README
M includes/objectcache/ObjectCache.php
M includes/objectcache/ObjectCacheSessionHandler.php
5 files changed, 11 insertions(+), 16 deletions(-)

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



diff --git a/includes/cache/CacheDependency.php 
b/includes/cache/CacheDependency.php
index 2abcabd..0a45b8e 100644
--- a/includes/cache/CacheDependency.php
+++ b/includes/cache/CacheDependency.php
@@ -98,7 +98,7 @@
         * it will be generated with the callback function (if present), and 
the newly
         * calculated value will be stored to the cache in a wrapper.
         *
-        * @param BagOStuff $cache A cache object such as $wgMemc
+        * @param BagOStuff $cache A cache object
         * @param string $key The cache key
         * @param int $expiry The expiry timestamp or interval in seconds
         * @param bool|callable $callback The callback for generating the 
value, or false
diff --git a/includes/deferred/SiteStatsUpdate.php 
b/includes/deferred/SiteStatsUpdate.php
index d135a80..73de755 100644
--- a/includes/deferred/SiteStatsUpdate.php
+++ b/includes/deferred/SiteStatsUpdate.php
@@ -207,8 +207,7 @@
         * @param int $delta Delta (positive or negative)
         */
        protected function adjustPending( $type, $delta ) {
-               global $wgMemc;
-
+               $cache = ObjectCache::getMainStashInstance();
                if ( $delta < 0 ) { // decrement
                        $key = $this->getTypeCacheKey( $type, '-' );
                } else { // increment
@@ -216,11 +215,7 @@
                }
 
                $magnitude = abs( $delta );
-               if ( !$wgMemc->incr( $key, $magnitude ) ) { // not there?
-                       if ( !$wgMemc->add( $key, $magnitude ) ) { // race?
-                               $wgMemc->incr( $key, $magnitude );
-                       }
-               }
+               $cache->incrWithInit( $key, 0, $magnitude, $magnitude );
        }
 
        /**
@@ -228,15 +223,16 @@
         * @return array Positive and negative deltas for each type
         */
        protected function getPendingDeltas() {
-               global $wgMemc;
+               $cache = ObjectCache::getMainStashInstance();
 
                $pending = array();
                foreach ( array( 'ss_total_edits',
                        'ss_good_articles', 'ss_total_pages', 'ss_users', 
'ss_images' ) as $type
                ) {
                        // Get pending increments and pending decrements
-                       $pending[$type]['+'] = (int)$wgMemc->get( 
$this->getTypeCacheKey( $type, '+' ) );
-                       $pending[$type]['-'] = (int)$wgMemc->get( 
$this->getTypeCacheKey( $type, '-' ) );
+                       $flg = BagOStuff::READ_LATEST;
+                       $pending[$type]['+'] = (int)$cache->get( 
$this->getTypeCacheKey( $type, '+' ), $flg );
+                       $pending[$type]['-'] = (int)$cache->get( 
$this->getTypeCacheKey( $type, '-' ), $flg );
                }
 
                return $pending;
@@ -247,12 +243,12 @@
         * @param array $pd Result of getPendingDeltas(), used for DB update
         */
        protected function removePendingDeltas( array $pd ) {
-               global $wgMemc;
+               $cache = ObjectCache::getMainStashInstance();
 
                foreach ( $pd as $type => $deltas ) {
                        foreach ( $deltas as $sign => $magnitude ) {
                                // Lower the pending counter now that we 
applied these changes
-                               $wgMemc->decr( $this->getTypeCacheKey( $type, 
$sign ), $magnitude );
+                               $cache->decr( $this->getTypeCacheKey( $type, 
$sign ), $magnitude );
                        }
                }
        }
diff --git a/includes/jobqueue/README b/includes/jobqueue/README
index c11d5a7..af836bc 100644
--- a/includes/jobqueue/README
+++ b/includes/jobqueue/README
@@ -61,7 +61,6 @@
 of which queues are ready.
 
 The following queue aggregator classes are available:
-* JobQueueAggregatorMemc (uses $wgMemc to track ready queues)
 * JobQueueAggregatorRedis (uses a redis server to track ready queues)
 
 Some aggregators cache data for a few minutes while others may be always up to 
date.
diff --git a/includes/objectcache/ObjectCache.php 
b/includes/objectcache/ObjectCache.php
index 3d14c33..27d8802 100644
--- a/includes/objectcache/ObjectCache.php
+++ b/includes/objectcache/ObjectCache.php
@@ -63,7 +63,7 @@
  *   Purpose: Memory storage for per-cluster coordination and tracking.
  *   A typical use case would be a rate limit counter or cache regeneration 
mutex.
  *   Stored centrally within the local data-center. Not replicated to other 
DCs.
- *   Also known as $wgMemc. Configured by $wgMainCacheType.
+ *   Configured by $wgMainCacheType.
  *
  * - wfGetCache( $cacheType )
  *   Get a specific cache type by key in $wgObjectCaches.
diff --git a/includes/objectcache/ObjectCacheSessionHandler.php 
b/includes/objectcache/ObjectCacheSessionHandler.php
index 2a5d695..cc85074 100644
--- a/includes/objectcache/ObjectCacheSessionHandler.php
+++ b/includes/objectcache/ObjectCacheSessionHandler.php
@@ -47,7 +47,7 @@
 
                // It's necessary to register a shutdown function to call 
session_write_close(),
                // because by the time the request shutdown function for the 
session module is
-               // called, $wgMemc has already been destroyed. Shutdown 
functions registered
+               // called, the BagOStuff has already been destroyed. Shutdown 
functions registered
                // this way are called before object destruction.
                register_shutdown_function( array( __CLASS__, 'handleShutdown' 
) );
        }

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

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

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

Reply via email to