} else {
$expiry = 86400; // has invalidation, 1 day
}
+
$cachedValue = $cache->get( $memcKey );
if ( $cachedValue === ' ' || $cachedValue === '' ) {
// Does not exist
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 );
+ $cache->set( $memcKey, " ", $expiry, $opts );
return false;
}
if ( $row && $row->rd_namespace == NS_FILE ) {
$targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title );
- $cache->set( $memcKey, $targetTitle->getDBkey(), $expiry );
+ $cache->set( $memcKey, $targetTitle->getDBkey(), $expiry, $opts );
return $targetTitle;
} else {
- $cache->set( $memcKey, '', $expiry );
+ $cache->set( $memcKey, '', $expiry, $opts );
return false;
}
$dbr = $this->getSlaveDB();
$id = $dbr->selectField(
'page', // Table
- 'page_id', //Field
- array( //Conditions
+ 'page_id', // Field
+ array( // Conditions
'page_namespace' => $title->getNamespace(),
'page_title' => $title->getDBkey(),
),
- __METHOD__ //Function name
+ __METHOD__ // Function name
);
return $id;
*/
function findBySha1s( array $hashes ) {
if ( !count( $hashes ) ) {
- return array(); //empty parameter
+ return array(); // empty parameter
}
$dbr = $this->getSlaveDB();
* @return void
*/
function invalidateImageRedirect( Title $title ) {
- $cache = ObjectCache::getMainWANInstance();
-
- $memcKey = $this->getSharedCacheKey( 'image_redirect', md5( $title->getDBkey() ) );
- if ( $memcKey ) {
- // Set a temporary value for the cache key, to ensure
- // that this value stays purged long enough so that
- // it isn't refreshed with a stale value due to a
- // lagged slave.
- $cache->delete( $memcKey, 12 );
+ $key = $this->getSharedCacheKey( 'image_redirect', md5( $title->getDBkey() ) );
+ if ( $key ) {
+ $this->getMasterDB()->onTransactionPreCommitOrIdle( function() use ( $key ) {
+ ObjectCache::getMainWANInstance()->delete( $key );
+ } );
}
}