MediaWiki
REL1_24
|
Class for handling resource locking. More...
Public Member Functions | |
__construct (array $config) | |
Construct a new instance from configuration. | |
lock (array $paths, $type=self::LOCK_EX, $timeout=0) | |
Lock the resources at the given abstract paths. | |
lockByType (array $pathsByType, $timeout=0) | |
Lock the resources at the given abstract paths. | |
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. | |
Public Attributes | |
const | LOCK_EX = 3 |
const | LOCK_SH = 1 |
Lock types; stronger locks have higher values. | |
const | LOCK_UW = 2 |
Protected Member Functions | |
doLock (array $paths, $type) | |
Lock resources with the given keys and lock type. | |
doLockByType (array $pathsByType) | |
doUnlock (array $paths, $type) | |
Unlock resources with the given keys and lock type. | |
doUnlockByType (array $pathsByType) | |
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. | |
sha1Base16Absolute ($path) | |
Get the base 16 SHA-1 of a string, padded to 31 digits. | |
sha1Base36Absolute ($path) | |
Get the base 36 SHA-1 of a string, padded to 31 digits. | |
Protected Attributes | |
$domain | |
array | $locksHeld = array() |
Map of (resource path => lock type => count) *. | |
$lockTTL | |
array | $lockTypeMap |
Mapping of lock types to the type actually used *. |
Class for handling resource locking.
Locks on resource keys can either be shared or exclusive.
Implementations must keep track of what is locked by this proccess in-memory and support nested locking calls (using reference counting). At least LOCK_UW and LOCK_EX must be implemented. LOCK_SH can be a no-op. Locks should either be non-blocking or have low wait timeouts.
Subclasses should avoid throwing exceptions at all costs.
Definition at line 45 of file LockManager.php.
LockManager::__construct | ( | array $ | config | ) |
Construct a new instance from configuration.
array | $config | Paramaters include:
|
Reimplemented in DBLockManager, RedisLockManager, MemcLockManager, and FSLockManager.
Definition at line 70 of file LockManager.php.
LockManager::doLock | ( | array $ | paths, |
$ | type | ||
) | [abstract, protected] |
Lock resources with the given keys and lock type.
array | $paths | List of paths |
int | $type | LockManager::LOCK_* constant |
Reimplemented in NullLockManager, FSLockManager, and QuorumLockManager.
LockManager::doLockByType | ( | array $ | pathsByType | ) | [protected] |
array | $pathsByType | Map of LockManager::LOCK_* constants to lists of paths |
Reimplemented in QuorumLockManager.
Definition at line 196 of file LockManager.php.
LockManager::doUnlock | ( | array $ | paths, |
$ | type | ||
) | [abstract, protected] |
Unlock resources with the given keys and lock type.
array | $paths | List of paths |
int | $type | LockManager::LOCK_* constant |
Reimplemented in NullLockManager, FSLockManager, and QuorumLockManager.
LockManager::doUnlockByType | ( | array $ | pathsByType | ) | [protected] |
array | $pathsByType | Map of LockManager::LOCK_* constants to lists of paths |
Reimplemented in QuorumLockManager.
Definition at line 230 of file LockManager.php.
LockManager::lock | ( | array $ | paths, |
$ | type = self::LOCK_EX , |
||
$ | timeout = 0 |
||
) | [final] |
Lock the resources at the given abstract paths.
array | $paths | List of resource names |
int | $type | LockManager::LOCK_* constant |
int | $timeout | Timeout in seconds (0 means non-blocking) (since 1.21) |
Definition at line 90 of file LockManager.php.
LockManager::lockByType | ( | array $ | pathsByType, |
$ | timeout = 0 |
||
) | [final] |
Lock the resources at the given abstract paths.
array | $pathsByType | Map of LockManager::LOCK_* constants to lists of paths |
int | $timeout | Timeout in seconds (0 means non-blocking) (since 1.21) |
Definition at line 102 of file LockManager.php.
LockManager::normalizePathsByType | ( | array $ | pathsByType | ) | [final, protected] |
Normalize the $paths array by converting LOCK_UW locks into the appropriate type and removing any duplicated paths for each lock type.
array | $pathsByType | Map of LockManager::LOCK_* constants to lists of paths |
Definition at line 181 of file LockManager.php.
LockManager::sha1Base16Absolute | ( | $ | path | ) | [final, protected] |
Get the base 16 SHA-1 of a string, padded to 31 digits.
Before hashing, the path will be prefixed with the domain ID. This should be used interally for lock key or file names.
string | $path |
Definition at line 169 of file LockManager.php.
LockManager::sha1Base36Absolute | ( | $ | path | ) | [final, protected] |
Get the base 36 SHA-1 of a string, padded to 31 digits.
Before hashing, the path will be prefixed with the domain ID. This should be used interally for lock key or file names.
string | $path |
Definition at line 157 of file LockManager.php.
LockManager::unlock | ( | array $ | paths, |
$ | type = self::LOCK_EX |
||
) | [final] |
Unlock the resources at the given abstract paths.
array | $paths | List of paths |
int | $type | LockManager::LOCK_* constant |
Definition at line 129 of file LockManager.php.
LockManager::unlockByType | ( | array $ | pathsByType | ) | [final] |
Unlock the resources at the given abstract paths.
array | $pathsByType | Map of LockManager::LOCK_* constants to lists of paths |
Definition at line 140 of file LockManager.php.
LockManager::$domain [protected] |
Definition at line 54 of file LockManager.php.
Map of (resource path => lock type => count) *.
Definition at line 52 of file LockManager.php.
LockManager::$lockTTL [protected] |
Definition at line 55 of file LockManager.php.
array LockManager::$lockTypeMap [protected] |
array( self::LOCK_SH => self::LOCK_SH, self::LOCK_UW => self::LOCK_EX, self::LOCK_EX => self::LOCK_EX )
Mapping of lock types to the type actually used *.
Reimplemented in PostgreSqlLockManager, MySqlLockManager, RedisLockManager, MemcLockManager, and FSLockManager.
Definition at line 46 of file LockManager.php.
const LockManager::LOCK_EX = 3 |
Definition at line 60 of file LockManager.php.
Referenced by SyncFileBackend\syncFileBatch().
const LockManager::LOCK_SH = 1 |
Lock types; stronger locks have higher values.
Definition at line 58 of file LockManager.php.
const LockManager::LOCK_UW = 2 |
Definition at line 59 of file LockManager.php.
Referenced by SyncFileBackend\syncFileBatch().