Request-local caching of image_redirect
authorOri Livneh <ori@wikimedia.org>
Thu, 24 Mar 2016 22:50:44 +0000 (15:50 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 25 Mar 2016 19:09:10 +0000 (12:09 -0700)
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
includes/libs/objectcache/WANObjectCache.php
tests/phpunit/MediaWikiTestCase.php

index d24aa24..d038d93 100644 (file)
@@ -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
index e43d37b..b212e97 100644 (file)
@@ -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
         *
index 4d0e39c..a99b4b9 100644 (file)
@@ -247,6 +247,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                }
 
                DeferredUpdates::clearPendingUpdates();
+               ObjectCache::getMainWANInstance()->clearProcessCache();
 
                ob_start( 'MediaWikiTestCase::wfResetOutputBuffersBarrier' );
        }