Merge "rdbms: make FakeResultWrapper use get_object_vars() again"
[lhc/web/wiklou.git] / includes / libs / lockmanager / MemcLockManager.php
index ebd72de..7f5f003 100644 (file)
@@ -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 ) {
@@ -89,7 +89,7 @@ class MemcLockManager extends QuorumLockManager {
 
                $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 );
@@ -164,7 +164,7 @@ class MemcLockManager extends QuorumLockManager {
 
                $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 );
@@ -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;