Merge "filerepo: make LocalRepo::getSharedCacheKey() use makeGlobalKey()"

This commit is contained in:
jenkins-bot 2020-05-23 17:54:18 +00:00 committed by Gerrit Code Review
commit b336d9ba83
2 changed files with 9 additions and 6 deletions

View file

@ -197,9 +197,9 @@ class LocalRepo extends FileRepo {
public function checkRedirect( Title $title ) {
$title = File::normalizeTitle( $title, 'exception' );
$memcKey = $this->getSharedCacheKey( 'image_redirect', md5( $title->getDBkey() ) );
$memcKey = $this->getSharedCacheKey( 'file_redirect', md5( $title->getDBkey() ) );
if ( $memcKey === false ) {
$memcKey = $this->getLocalCacheKey( 'image_redirect', md5( $title->getDBkey() ) );
$memcKey = $this->getLocalCacheKey( 'file_redirect', md5( $title->getDBkey() ) );
$expiry = 300; // no invalidation, 5 minutes
} else {
$expiry = 86400; // has invalidation, 1 day
@ -497,7 +497,10 @@ class LocalRepo extends FileRepo {
* @return string
*/
public function getSharedCacheKey( ...$args ) {
return $this->wanCache->makeKey( ...$args );
return $this->wanCache->makeGlobalKey(
WikiMap::getCurrentWikiDbDomain()->getId(),
...$args
);
}
/**
@ -507,7 +510,7 @@ class LocalRepo extends FileRepo {
* @return void
*/
public function invalidateImageRedirect( Title $title ) {
$key = $this->getSharedCacheKey( 'image_redirect', md5( $title->getDBkey() ) );
$key = $this->getSharedCacheKey( 'file_redirect', md5( $title->getDBkey() ) );
if ( $key ) {
$this->getMasterDB()->onTransactionPreCommitOrIdle(
function () use ( $key ) {

View file

@ -177,8 +177,8 @@ class LocalRepoTest extends MediaWikiIntegrationTestCase {
->setMethods( [ 'makeKey' ] )
->getMock();
$mockWan->expects( $this->exactly( 2 ) )->method( 'makeKey' )->withConsecutive(
[ 'image_redirect', md5( 'Redirect' ) ],
[ 'filerepo', 'local', 'image_redirect', md5( 'Redirect' ) ]
[ 'file_redirect', md5( 'Redirect' ) ],
[ 'filerepo', 'local', 'file_redirect', md5( 'Redirect' ) ]
)->will( $this->onConsecutiveCalls( false, 'somekey' ) );
$repo = $this->newRepo( [ 'wanCache' => $mockWan ] );