}
if ( !$success ) {
- $cacheKey = $this->clusterCache->makeKey( 'messages', $code ); # Key in memc for messages
+ $cacheKey = $this->clusterCache->makeKey( 'messages', $code );
# Try the global cache. If it is empty, try to acquire a lock. If
# the lock can't be acquired, wait for the other thread to finish
# and then try the global cache a second time.
// Relay the purge. Touching this check key expires cache contents
// and local cache (APC) validation hash across all datacenters.
- $this->wanCache->touchCheckKey( $this->wanCache->makeKey( 'messages', $code ) );
- // Also delete cached sidebar... just in case it is affected
- // @TODO: shouldn't this be $code === $wgLanguageCode?
- if ( $code === 'en' ) {
- // Purge all language sidebars, e.g. on ?action=purge to the sidebar messages
- $codes = array_keys( Language::fetchLanguageNames() );
- } else {
- // Purge only the sidebar for this language
- $codes = [ $code ];
- }
- foreach ( $codes as $code ) {
- $this->wanCache->delete( $this->wanCache->makeKey( 'sidebar', $code ) );
- }
+ $this->wanCache->touchCheckKey( $this->getCheckKey( $code ) );
// Purge the message in the message blob store
$resourceloader = RequestContext::getMain()->getOutput()->getResourceLoader();
$value = $this->wanCache->get(
$this->wanCache->makeKey( 'messages', $code, 'hash', 'v1' ),
$curTTL,
- [ $this->wanCache->makeKey( 'messages', $code ) ]
+ [ $this->getCheckKey( $code ) ]
);
if ( $value ) {
}
/**
- * Clear all stored messages. Mainly used after a mass rebuild.
+ * Clear all stored messages in global and local cache
+ *
+ * Mainly used after a mass rebuild
*/
function clear() {
$langs = Language::fetchLanguageNames( null, 'mw' );
foreach ( array_keys( $langs ) as $code ) {
- # Global and local caches
- $this->wanCache->touchCheckKey( $this->wanCache->makeKey( 'messages', $code ) );
+ $this->wanCache->touchCheckKey( $this->getCheckKey( $code ) );
}
$this->mLoadedLanguages = [];
}
}
+ /**
+ * @param string $code Language code
+ * @return string WAN cache key usable as a "check key" against language page edits
+ */
+ public function getCheckKey( $code ) {
+ return $this->wanCache->makeKey( 'messages', $code );
+ }
+
/**
* @param Content|null $content Content or null if the message page does not exist
* @return string|bool|null Returns false if $content is null and null on error
*
* @return array
*/
- function buildSidebar() {
+ public function buildSidebar() {
global $wgEnableSidebarCache, $wgSidebarCacheExpiry;
$callback = function ( $old = null, &$ttl = null ) {
return $bar;
};
- $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $msgCache = MessageCache::singleton();
+ $wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+
$sidebar = $wgEnableSidebarCache
- ? $cache->getWithSetCallback(
- $cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
+ ? $wanCache->getWithSetCallback(
+ $wanCache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
$wgSidebarCacheExpiry,
$callback,
- [ 'lockTSE' => 30 ]
+ [
+ 'checkKeys' => [
+ // Unless there is both no exact $code override nor an i18n definition
+ // in the the software, the only MediaWiki page to check is for $code.
+ $msgCache->getCheckKey( $this->getLanguage()->getCode() )
+ ],
+ 'lockTSE' => 30
+ ]
)
: $callback();