From: Aaron Schulz Date: Thu, 28 Feb 2019 01:13:40 +0000 (-0800) Subject: obectcache: split out some WAN cache refresh logic into scheduleAsyncRefresh() X-Git-Tag: 1.34.0-rc.0~2694^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22config_fonctions%22%2C%20%22image_process=%24process%22%29%20.%20%22?a=commitdiff_plain;h=6ee5cdd10b2d88761f26b2a41c9dd300e9db8206;p=lhc%2Fweb%2Fwiklou.git obectcache: split out some WAN cache refresh logic into scheduleAsyncRefresh() Change-Id: If5f895a0d38cd0d6861125000df4fcfc66f1eeb3 --- diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 976c176203..0480d71ba9 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -1271,13 +1271,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $this->stats->increment( "wanobjectcache.$kClass.hit.good" ); return $value; - } elseif ( $this->asyncHandler ) { - // Update the cache value later, such during post-send of an HTTP request - $func = $this->asyncHandler; - $func( function () use ( $key, $ttl, $callback, $opts, $asOf ) { - $opts['minAsOf'] = INF; // force a refresh - $this->doGetWithSetCallback( $key, $ttl, $callback, $opts, $asOf ); - } ); + } elseif ( $this->scheduleAsyncRefresh( $key, $ttl, $callback, $opts ) ) { $this->stats->increment( "wanobjectcache.$kClass.hit.refresh" ); return $value; @@ -2012,6 +2006,28 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { return $ok; } + /** + * @param string $key + * @param int $ttl + * @param callable $callback + * @param array $opts + * @return bool Success + */ + private function scheduleAsyncRefresh( $key, $ttl, $callback, $opts ) { + if ( !$this->asyncHandler ) { + return false; + } + // Update the cache value later, such during post-send of an HTTP request + $func = $this->asyncHandler; + $func( function () use ( $key, $ttl, $callback, $opts ) { + $asOf = null; // unused + $opts['minAsOf'] = INF; // force a refresh + $this->doGetWithSetCallback( $key, $ttl, $callback, $opts, $asOf ); + } ); + + return true; + } + /** * Check if a key is fresh or in the grace window and thus due for randomized reuse *