objectcache: Run preemptive WAN cache refreshes post-send
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index 6d6d345..07432c0 100644 (file)
@@ -332,6 +332,8 @@ class ObjectCache {
         * @throws UnexpectedValueException
         */
        public static function newWANCacheFromParams( array $params ) {
+               global $wgCommandLineMode;
+
                $services = MediaWikiServices::getInstance();
 
                $erGroup = $services->getEventRelayerGroup();
@@ -346,6 +348,10 @@ class ObjectCache {
                } else {
                        $params['logger'] = LoggerFactory::getInstance( 'objectcache' );
                }
+               // Let pre-emptive refreshes happen post-send on HTTP requests
+               if ( !$wgCommandLineMode ) {
+                       $params['asyncHandler'] = [ DeferredUpdates::class, 'addCallableUpdate' ];
+               }
                $class = $params['class'];
 
                return new $class( $params );