* @return void
*/
public function clearCache() {
- wfSuppressWarnings();
+ MediaWiki\suppressWarnings();
unlink( $this->cachePath() );
- wfRestoreWarnings();
+ MediaWiki\restoreWarnings();
$this->mCached = false;
}
* @return void
*/
public function incrMissesRecent( WebRequest $request ) {
- global $wgMemc;
if ( mt_rand( 0, self::MISS_FACTOR - 1 ) == 0 ) {
+ $cache = ObjectCache::getLocalClusterInstance();
# Get a large IP range that should include the user even if that
# person's IP address changes
$ip = $request->getIP();
# Bail out if a request already came from this range...
$key = wfMemcKey( get_class( $this ), 'attempt', $this->mType, $this->mKey, $ip );
- if ( $wgMemc->get( $key ) ) {
+ if ( $cache->get( $key ) ) {
return; // possibly the same user
}
- $wgMemc->set( $key, 1, self::MISS_TTL_SEC );
+ $cache->set( $key, 1, self::MISS_TTL_SEC );
# Increment the number of cache misses...
$key = $this->cacheMissKey();
- if ( $wgMemc->get( $key ) === false ) {
- $wgMemc->set( $key, 1, self::MISS_TTL_SEC );
+ if ( $cache->get( $key ) === false ) {
+ $cache->set( $key, 1, self::MISS_TTL_SEC );
} else {
- $wgMemc->incr( $key );
+ $cache->incr( $key );
}
}
}
* @return int
*/
public function getMissesRecent() {
- global $wgMemc;
+ $cache = ObjectCache::getLocalClusterInstance();
- return self::MISS_FACTOR * $wgMemc->get( $this->cacheMissKey() );
+ return self::MISS_FACTOR * $cache->get( $this->cacheMissKey() );
}
/**