/** @var MemcachedBagOStuff[] Map of (server name => MemcachedBagOStuff) */
protected $cacheServers = [];
- /** @var HashBagOStuff Server status cache */
+ /** @var MapCacheLRU Server status cache */
protected $statusCache;
/**
$this->srvsByBucket = array_filter( $config['srvsByBucket'], 'is_array' );
$this->srvsByBucket = array_values( $this->srvsByBucket ); // consecutive
- $memcConfig = isset( $config['memcConfig'] ) ? $config['memcConfig'] : [];
+ $memcConfig = $config['memcConfig'] ?? [];
$memcConfig += [ 'class' => MemcachedPhpBagOStuff::class ]; // default
$class = $memcConfig['class'];
$this->cacheServers[$name] = new $class( $params );
}
- $this->statusCache = new HashBagOStuff();
+ $this->statusCache = new MapCacheLRU( 100 );
}
protected function getLocksOnServer( $lockSrv, array $pathsByType ) {
$memc = $this->getCache( $lockSrv );
// List of affected paths
- $paths = call_user_func_array( 'array_merge', array_values( $pathsByType ) );
+ $paths = array_merge( ...array_values( $pathsByType ) );
$paths = array_unique( $paths );
// List of affected lock record keys
$keys = array_map( [ $this, 'recordKeyForPath' ], $paths );
$memc = $this->getCache( $lockSrv );
// List of affected paths
- $paths = call_user_func_array( 'array_merge', array_values( $pathsByType ) );
+ $paths = array_merge( ...array_values( $pathsByType ) );
$paths = array_unique( $paths );
// List of affected lock record keys
$keys = array_map( [ $this, 'recordKeyForPath' ], $paths );
throw new InvalidArgumentException( "Invalid cache server '$lockSrv'." );
}
- $online = $this->statusCache->get( "online:$lockSrv" );
- if ( $online === false ) {
+ $online = $this->statusCache->get( "online:$lockSrv", 30 );
+ if ( $online === null ) {
$online = $this->cacheServers[$lockSrv]->set( __CLASS__ . ':ping', 1, 1 );
if ( !$online ) { // server down?
$this->logger->warning( __METHOD__ . ": Could not contact $lockSrv." );
}
- $this->statusCache->set( "online:$lockSrv", (int)$online, 30 );
+ $this->statusCache->set( "online:$lockSrv", (int)$online );
}
return $online ? $this->cacheServers[$lockSrv] : null;