From: Aaron Schulz Date: Wed, 18 Jul 2018 00:01:56 +0000 (+0100) Subject: Convert MemcLockManager to using MapCacheLRU X-Git-Tag: 1.34.0-rc.0~4717^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=01165d46c40e1a020c9b072ca061d35325b53d29;p=lhc%2Fweb%2Fwiklou.git Convert MemcLockManager to using MapCacheLRU Change-Id: Ia376641f29c1d9acc51268afb9319ab0beab5528 --- diff --git a/includes/libs/lockmanager/MemcLockManager.php b/includes/libs/lockmanager/MemcLockManager.php index f1f749faa0..7f5f003df9 100644 --- a/includes/libs/lockmanager/MemcLockManager.php +++ b/includes/libs/lockmanager/MemcLockManager.php @@ -46,7 +46,7 @@ class MemcLockManager extends QuorumLockManager { /** @var MemcachedBagOStuff[] Map of (server name => MemcachedBagOStuff) */ protected $cacheServers = []; - /** @var HashBagOStuff Server status cache */ + /** @var MapCacheLRU Server status cache */ protected $statusCache; /** @@ -81,7 +81,7 @@ class MemcLockManager extends QuorumLockManager { $this->cacheServers[$name] = new $class( $params ); } - $this->statusCache = new HashBagOStuff(); + $this->statusCache = new MapCacheLRU( 100 ); } protected function getLocksOnServer( $lockSrv, array $pathsByType ) { @@ -252,13 +252,13 @@ class MemcLockManager extends QuorumLockManager { 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;