- $cachedValue = $cache->get( $memcKey );
- if ( $cachedValue === ' ' || $cachedValue === '' ) {
- // Does not exist
- return false;
- } elseif ( strval( $cachedValue ) !== '' && $cachedValue !== ' PURGED' ) {
- return Title::newFromText( $cachedValue, NS_FILE );
- } // else $cachedValue is false or null: cache miss
-
- $opts = array( 'since' => $this->getSlaveDB()->trxTimestamp() );
-
- $id = $this->getArticleID( $title );
- if ( !$id ) {
- $cache->set( $memcKey, " ", $expiry, $opts );
+ $that = $this;
+ $redirDbKey = ObjectCache::getMainWANInstance()->getWithSetCallback(
+ $memcKey,
+ function ( $oldValue, &$ttl, array &$setOpts ) use ( $that, $title ) {
+ $dbr = $that->getSlaveDB(); // possibly remote DB
+
+ $setOpts = array( 'since' => $dbr->trxTimestamp() );
+
+ if ( $title instanceof Title ) {
+ $row = $dbr->selectRow(
+ array( 'page', 'redirect' ),
+ array( 'rd_namespace', 'rd_title' ),
+ array(
+ 'page_namespace' => $title->getNamespace(),
+ 'page_title' => $title->getDBkey(),
+ 'rd_from = page_id'
+ ),
+ __METHOD__
+ );
+ } else {
+ $row = false;
+ }