*/
class RedisLockManager extends QuorumLockManager {
/** @var array Mapping of lock types to the type actually used */
- protected $lockTypeMap = array(
+ protected $lockTypeMap = [
self::LOCK_SH => self::LOCK_SH,
self::LOCK_UW => self::LOCK_SH,
self::LOCK_EX => self::LOCK_EX
- );
+ ];
/** @var RedisConnectionPool */
protected $redisPool;
/** @var array Map server names to hostname/IP and port numbers */
- protected $lockServers = array();
+ protected $lockServers = [];
/** @var string Random UUID */
protected $session = '';
* - srvsByBucket : Array of 1-16 consecutive integer keys, starting from 0,
* each having an odd-numbered list of server names (peers) as values.
* - redisConfig : Configuration for RedisConnectionPool::__construct().
- * @throws MWException
+ * @throws Exception
*/
public function __construct( array $config ) {
parent::__construct( $config );
return $status;
}
- $pathsByKey = array(); // (type:hash => path) map
+ $pathsByKey = []; // (type:hash => path) map
foreach ( $pathsByType as $type => $paths ) {
$typeString = ( $type == LockManager::LOCK_SH ) ? 'SH' : 'EX';
foreach ( $paths as $path ) {
$res = $conn->luaEval( $script,
array_merge(
array_keys( $pathsByKey ), // KEYS[0], KEYS[1],...,KEYS[N]
- array(
+ [
$this->session, // ARGV[1]
$this->lockTTL, // ARGV[2]
time() // ARGV[3]
- )
+ ]
),
count( $pathsByKey ) # number of first argument(s) that are keys
);
return $status;
}
- $pathsByKey = array(); // (type:hash => path) map
+ $pathsByKey = []; // (type:hash => path) map
foreach ( $pathsByType as $type => $paths ) {
$typeString = ( $type == LockManager::LOCK_SH ) ? 'SH' : 'EX';
foreach ( $paths as $path ) {
$res = $conn->luaEval( $script,
array_merge(
array_keys( $pathsByKey ), // KEYS[0], KEYS[1],...,KEYS[N]
- array(
+ [
$this->session, // ARGV[1]
- )
+ ]
),
count( $pathsByKey ) # number of first argument(s) that are keys
);
*/
protected function recordKeyForPath( $path, $type ) {
return implode( ':',
- array( __CLASS__, 'locks', "$type:" . $this->sha1Base36Absolute( $path ) ) );
+ [ __CLASS__, 'locks', "$type:" . $this->sha1Base36Absolute( $path ) ] );
}
/**
*/
function __destruct() {
while ( count( $this->locksHeld ) ) {
- $pathsByType = array();
+ $pathsByType = [];
foreach ( $this->locksHeld as $path => $locks ) {
foreach ( $locks as $type => $count ) {
$pathsByType[$type][] = $path;