From d1c4eafef54f638ef025816b17502250a5be9e73 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Thu, 24 Mar 2016 15:50:44 -0700 Subject: [PATCH] Request-local caching of image_redirect LocalRepo::checkRedirect() cache image redirect checks in memory to avoid unnecessary trips to memcached. Same idea as Idbd11637. Change-Id: Idaa12376382aaa0bd8cb988240ec1da0b688359d --- includes/filerepo/LocalRepo.php | 3 ++- includes/libs/objectcache/WANObjectCache.php | 9 +++++++++ tests/phpunit/MediaWikiTestCase.php | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index d24aa24cba..d038d937c4 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -226,7 +226,8 @@ class LocalRepo extends FileRepo { return ( $row && $row->rd_namespace == NS_FILE ) ? Title::makeTitle( $row->rd_namespace, $row->rd_title )->getDBkey() : ''; // negative cache - } + }, + [ 'pcTTL' => $expiry ] ); // @note: also checks " " for b/c diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index e43d37b8ca..b212e9779d 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -918,6 +918,15 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $this->lastRelayError = self::ERR_NONE; } + /** + * Clear the in-process caches; useful for testing + * + * @since 1.27 + */ + public function clearProcessCache() { + $this->procCache->clear(); + } + /** * Do the actual async bus purge of a key * diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 4d0e39c1d2..a99b4b926b 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -247,6 +247,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } DeferredUpdates::clearPendingUpdates(); + ObjectCache::getMainWANInstance()->clearProcessCache(); ob_start( 'MediaWikiTestCase::wfResetOutputBuffersBarrier' ); } -- 2.20.1