private $chronProt;
/** @var BagOStuff */
private $srvCache;
- /** @var BagOStuff */
- private $memCache;
/** @var WANObjectCache */
private $wanCache;
/** @var object|string Class name or object With profileIn/profileOut methods */
} else {
$this->srvCache = new EmptyBagOStuff();
}
- if ( isset( $params['memCache'] ) ) {
- $this->memCache = $params['memCache'];
- } else {
- $this->memCache = new EmptyBagOStuff();
- }
if ( isset( $params['wanCache'] ) ) {
$this->wanCache = $params['wanCache'];
} else {
}
$this->loadMonitor = new $class(
- $this, $this->srvCache, $this->memCache, $this->loadMonitorConfig );
+ $this, $this->srvCache, $this->wanCache, $this->loadMonitorConfig );
$this->loadMonitor->setLogger( $this->replLogger );
}
use Psr\Log\LoggerAwareInterface;
use BagOStuff;
+use WANObjectCache;
/**
* An interface for database load monitoring
*
* @param ILoadBalancer $lb LoadBalancer this instance serves
* @param BagOStuff $sCache Local server memory cache
- * @param BagOStuff $cCache Local cluster memory cache
+ * @param WANObjectCache $wCache Local cluster memory cache
* @param array $options Options map
*/
public function __construct(
- ILoadBalancer $lb, BagOStuff $sCache, BagOStuff $cCache, array $options = []
+ ILoadBalancer $lb, BagOStuff $sCache, WANObjectCache $wCache, array $options = []
);
/**
use Psr\Log\NullLogger;
use Wikimedia\ScopedCallback;
use BagOStuff;
+use WANObjectCache;
/**
* Basic DB load monitor with no external dependencies
protected $parent;
/** @var BagOStuff */
protected $srvCache;
- /** @var BagOStuff */
- protected $mainCache;
+ /** @var WANObjectCache */
+ protected $wanCache;
/** @var LoggerInterface */
protected $replLogger;
const VERSION = 1; // cache key version
public function __construct(
- ILoadBalancer $lb, BagOStuff $srvCache, BagOStuff $cache, array $options = []
+ ILoadBalancer $lb, BagOStuff $srvCache, WANObjectCache $wCache, array $options = []
) {
$this->parent = $lb;
$this->srvCache = $srvCache;
- $this->mainCache = $cache;
+ $this->wanCache = $wCache;
$this->replLogger = new NullLogger();
$this->movingAveRatio = isset( $options['movingAveRatio'] )
$staleValue = $value ?: false;
# (b) Check the shared cache and backfill APC
- $value = $this->mainCache->get( $key );
+ $value = $this->wanCache->get( $key );
if ( $value && $value['timestamp'] > ( microtime( true ) - $ttl ) ) {
$this->srvCache->set( $key, $value, $staleTTL );
$this->replLogger->debug( __METHOD__ . ": got lag times ($key) from main cache" );
$staleValue = $value ?: $staleValue;
# (c) Cache key missing or expired; regenerate and backfill
- if ( $this->mainCache->lock( $key, 0, 10 ) ) {
- # Let this process alone update the cache value
- $cache = $this->mainCache;
+ if ( $this->srvCache->lock( $key, 0, 10 ) ) {
+ # Let only this process update the cache value on this server
+ $sCache = $this->srvCache;
/** @noinspection PhpUnusedLocalVariableInspection */
- $unlocker = new ScopedCallback( function () use ( $cache, $key ) {
- $cache->unlock( $key );
+ $unlocker = new ScopedCallback( function () use ( $sCache, $key ) {
+ $sCache->unlock( $key );
} );
} elseif ( $staleValue ) {
# Could not acquire lock but an old cache exists, so use it
'weightScales' => $weightScales,
'timestamp' => microtime( true )
];
- $this->mainCache->set( $key, $value, $staleTTL );
+ $this->wanCache->set( $key, $value, $staleTTL );
$this->srvCache->set( $key, $value, $staleTTL );
$this->replLogger->info( __METHOD__ . ": re-calculated lag times ($key)" );
namespace Wikimedia\Rdbms;
use BagOStuff;
+use WANObjectCache;
/**
* Basic MySQL load monitor with no external dependencies
private $warmCacheRatio;
public function __construct(
- ILoadBalancer $lb, BagOStuff $srvCache, BagOStuff $cache, array $options = []
+ ILoadBalancer $lb, BagOStuff $srvCache, WANObjectCache $wCache, array $options = []
) {
- parent::__construct( $lb, $srvCache, $cache, $options );
+ parent::__construct( $lb, $srvCache, $wCache, $options );
$this->warmCacheRatio = isset( $options['warmCacheRatio'] )
? $options['warmCacheRatio']