$data['mVersion'] = self::VERSION;
$key = wfMemcKey( 'user', 'id', $this->mId );
- $opts = DatabaseBase::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
+ $opts = Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
ObjectCache::getMainWANInstance()->set( $key, $data, 3600, $opts );
}
$dbr = wfGetDB( DB_SLAVE );
$dbrWatchlist = wfGetDB( DB_SLAVE, 'watchlist' );
- $setOpts += DatabaseBase::getCacheSetOptions( $dbr, $dbrWatchlist );
+ $setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist );
$result = array();
return ObjectCache::getMainWANInstance()->getWithSetCallback(
wfMemcKey( 'active-tags' ),
function ( $oldValue, &$ttl, array &$setOpts ) {
- $setOpts += DatabaseBase::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
+ $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
// Ask extensions which tags they consider active
$extensionActive = array();
function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
$dbr = wfGetDB( DB_SLAVE );
- $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+ $setOpts += Database::getCacheSetOptions( $dbr );
$tags = $dbr->selectFieldValues( 'valid_tag', 'vt_tag', array(), $fname );
return ObjectCache::getMainWANInstance()->getWithSetCallback(
wfMemcKey( 'valid-tags-hook' ),
function ( $oldValue, &$ttl, array &$setOpts ) {
- $setOpts += DatabaseBase::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
+ $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
$tags = array();
Hooks::run( 'ListDefinedTags', array( &$tags ) );
function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
$dbr = wfGetDB( DB_SLAVE, 'vslow' );
- $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+ $setOpts += Database::getCacheSetOptions( $dbr );
$res = $dbr->select(
'change_tag',
function ( $oldValue, &$ttl, array &$setOpts ) use ( $that, $title ) {
$dbr = $that->getSlaveDB(); // possibly remote DB
- $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+ $setOpts += Database::getCacheSetOptions( $dbr );
if ( $title instanceof Title ) {
$row = $dbr->selectRow(
// Cache presence for 1 week and negatives for 1 day
$ttl = $this->fileExists ? 86400 * 7 : 86400;
- $opts = DatabaseBase::getCacheSetOptions( $this->repo->getSlaveDB() );
+ $opts = Database::getCacheSetOptions( $this->repo->getSlaveDB() );
ObjectCache::getMainWANInstance()->set( $key, $cacheVal, $ttl, $opts );
}
function ( $oldValue, &$ttl, array &$setOpts ) use ( $prefix ) {
$dbr = wfGetDB( DB_SLAVE );
- $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+ $setOpts += Database::getCacheSetOptions( $dbr );
$row = $dbr->selectRow(
'interwiki',
* - d) T1 reads the row and calls set() due to a cache miss
* - e) Stale value is stuck in cache
*
+ * Setting 'lag' helps avoids keys getting stuck in long-term stale states.
+ *
* Example usage:
* @code
* $dbr = wfGetDB( DB_SLAVE );
- * $setOpts = DatabaseBase::getCacheSetOptions( $dbr );
+ * $setOpts = Database::getCacheSetOptions( $dbr );
* // Fetch the row from the DB
* $row = $dbr->selectRow( ... );
* $key = wfMemcKey( 'building', $buildingId );
* can be set dynamically by altering $ttl in the callback (by reference).
* The $setOpts array can be altered and is given to set() when called;
* it is recommended to set the 'since' field to avoid race conditions.
+ * Setting 'lag' helps avoids keys getting stuck in long-term stale states.
*
* Usually, callbacks ignore the current value, but it can be used
* to maintain "most recent X" values that come from time or sequence
* function ( $oldValue, &$ttl, array &$setOpts ) {
* $dbr = wfGetDB( DB_SLAVE );
* // Account for any snapshot/slave lag
- * $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+ * $setOpts += Database::getCacheSetOptions( $dbr );
*
* return $dbr->selectRow( ... );
* },
* function ( $oldValue, &$ttl, array &$setOpts ) {
* $dbr = wfGetDB( DB_SLAVE );
* // Account for any snapshot/slave lag
- * $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+ * $setOpts += Database::getCacheSetOptions( $dbr );
*
* return CatConfig::newFromRow( $dbr->selectRow( ... ) );
* },
* // Determine new value from the DB
* $dbr = wfGetDB( DB_SLAVE );
* // Account for any snapshot/slave lag
- * $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+ * $setOpts += Database::getCacheSetOptions( $dbr );
*
* return CatState::newFromResults( $dbr->select( ... ) );
* },
* function ( $oldValue, &$ttl, array &$setOpts ) {
* $dbr = wfGetDB( DB_SLAVE );
* // Account for any snapshot/slave lag
- * $setOpts += DatabaseBase::getCacheSetOptions( $dbr );
+ * $setOpts += Database::getCacheSetOptions( $dbr );
*
* // Start off with the last cached list
* $list = $oldValue ?: array();