MediaWiki master
Wikimedia\LockManager\DatabaseLockManager Class Reference

A simplified Database Lock Manager. More...

Inherits Wikimedia\LockManager\LockManager.

Collaboration diagram for Wikimedia\LockManager\DatabaseLockManager:

Public Member Functions

 __construct (array $config)
 Construct a new instance from configuration.
 
 lockByType (array $pathsByType, $timeout=0)
 Lock the resources at the given abstract paths.
Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
int$timeoutTimeout in seconds (0 means non-blocking) (since 1.21)
Returns
StatusValue
Since
1.22

 
- Public Member Functions inherited from Wikimedia\LockManager\LockManager
 lock (array $paths, $type=self::LOCK_EX, $timeout=0)
 Lock the resources at the given abstract paths.
 
 lockKey (string $key, int $timeout=0)
 Provide a mutex of the key.
Parameters
string$keyKey to lock (relative to a domain, usually represented by the wiki ID, which callers don't need to specify)
int$timeoutTime to wait in seconds
Returns
bool true if the lock is acquired, false otherwise

 
 scopedLock (string $key, int $timeout=0)
 Lock a key and unlock it automatically when the object is destructed.
Parameters
string$key
int$timeout
Returns
ScopedCallback|null returns null when we failed to acquire the lock

 
 unlock (array $paths, $type=self::LOCK_EX)
 Unlock the resources at the given abstract paths.
 
 unlockByType (array $pathsByType)
 Unlock the resources at the given abstract paths.
 
 unlockKey (string $key)
 
Parameters
string$keyKey to unlock (relative to a domain, usually represented by the wiki ID, which callers don't need to specify)
Returns
bool true if the lock is released, false otherwise

 

Protected Member Functions

 doLockByType (array $pathsByType)
 Since we are overriding ::lockByType, this should never be reached.
 
 doUnlockByType (array $pathsByType)
 Release a set of locks.
Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
Returns
StatusValue
See also
LockManager::unlockByType()

 
- Protected Member Functions inherited from Wikimedia\LockManager\LockManager
 normalizePathsByType (array $pathsByType)
 Normalize the $paths array by converting LOCK_UW locks into the appropriate type and removing any duplicated paths for each lock type.
 
 sha1Base36Absolute ( $path)
 Get the base 36 SHA-1 of a string, padded to 31 digits.
 

Additional Inherited Members

- Public Attributes inherited from Wikimedia\LockManager\LockManager
const LOCK_EX = 3
 
const LOCK_SH = 1
 Lock types; stronger locks have higher values.
 
const LOCK_UW = 2
 
- Protected Attributes inherited from Wikimedia\LockManager\LockManager
string $domain
 domain (usually wiki ID)
 
array $locksHeld = []
 Map of (resource path => lock type => count)
 
int $lockTTL
 maximum time locks can be held
 
array $lockTypeMap
 Mapping of lock types to the type actually used.
 
LoggerInterface $logger
 
string $session
 Random 32-char hex number.
 
const MAX_LOCK_TTL = 2 * 3600
 Max expected lock expiry in any context.
 
const MIN_LOCK_TTL = 5
 Minimum lock TTL.
 

Detailed Description

A simplified Database Lock Manager.

Definition at line 13 of file DatabaseLockManager.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\LockManager\DatabaseLockManager::__construct ( array $config)

Construct a new instance from configuration.

  • Parameters
    array$config

Reimplemented from Wikimedia\LockManager\LockManager.

Definition at line 22 of file DatabaseLockManager.php.

Member Function Documentation

◆ doLockByType()

Wikimedia\LockManager\DatabaseLockManager::doLockByType ( array $pathsByType)
protected

Since we are overriding ::lockByType, this should never be reached.

Returns
never

Reimplemented from Wikimedia\LockManager\LockManager.

Definition at line 103 of file DatabaseLockManager.php.

◆ doUnlockByType()

Wikimedia\LockManager\DatabaseLockManager::doUnlockByType ( array $pathsByType)
protected

Release a set of locks.

Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
Returns
StatusValue
See also
LockManager::unlockByType()

Reimplemented from Wikimedia\LockManager\LockManager.

Definition at line 68 of file DatabaseLockManager.php.

References Wikimedia\LockManager\LockManager\sha1Base36Absolute().

◆ lockByType()

Wikimedia\LockManager\DatabaseLockManager::lockByType ( array $pathsByType,
$timeout = 0 )

Lock the resources at the given abstract paths.

Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
int$timeoutTimeout in seconds (0 means non-blocking) (since 1.21)
Returns
StatusValue
Since
1.22

Reimplemented from Wikimedia\LockManager\LockManager.

Definition at line 32 of file DatabaseLockManager.php.

References Wikimedia\LockManager\LockManager\normalizePathsByType(), and Wikimedia\LockManager\LockManager\sha1Base36Absolute().


The documentation for this class was generated from the following file: