Inject getLocalServerObjectCache() into the CachingSiteStore instance
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 20 Jul 2019 21:09:31 +0000 (14:09 -0700)
committerJforrester <jforrester@wikimedia.org>
Fri, 26 Jul 2019 16:42:23 +0000 (16:42 +0000)
This means SiteStore now uses APCu on PHP7 as well. Previously it only
used APC on HHVM, and used the main cache (e.g. Memcached) on PHP7.

Change-Id: I83ff1d2dd61c611c9976c6f9ca8026a0b6dd6662

includes/ServiceWiring.php

index b6500a4..9073de1 100644 (file)
@@ -263,6 +263,7 @@ return [
 
        'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
                $cacheId = \ObjectCache::detectLocalServerCache();
+
                return \ObjectCache::newFromId( $cacheId );
        },
 
@@ -621,9 +622,10 @@ return [
        'SiteStore' => function ( MediaWikiServices $services ) : SiteStore {
                $rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
 
-               // TODO: replace wfGetCache with a CacheFactory service.
-               // TODO: replace wfIsHHVM with a capabilities service.
-               $cache = wfGetCache( wfIsHHVM() ? CACHE_ACCEL : CACHE_ANYTHING );
+               $cache = $services->getLocalServerObjectCache();
+               if ( $cache instanceof EmptyBagOStuff ) {
+                       $cache = ObjectCache::getLocalClusterInstance();
+               }
 
                return new CachingSiteStore( $rawSiteStore, $cache );
        },