PHP Class Elgg\Database\Mutex

Provides database mutex that can be used to prevent race conditions between two processes that affect the same data.
Since: 2.1.0
Afficher le fichier Open project: elgg/elgg Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( Database $db, Logger $logger ) Constructor
isLocked ( string $namespace ) : boolean Checks if mutex is locked
lock ( string $namespace ) : boolean Creates a table {prefix}{$namespace}_lock that is used as a mutex.
unlock ( string $namespace ) : void Unlocks mutex

Private Methods

Méthode Description
assertNamespace ( string $namespace ) : void Assert that the namespace contains only characters [A-Za-z]

Method Details

__construct() public méthode

Constructor
public __construct ( Database $db, Logger $logger )
$db Elgg\Database Database
$logger Elgg\Logger Logger

isLocked() public méthode

Checks if mutex is locked
public isLocked ( string $namespace ) : boolean
$namespace string Namespace to use for the database table
Résultat boolean

lock() public méthode

Creates a table {prefix}{$namespace}_lock that is used as a mutex.
public lock ( string $namespace ) : boolean
$namespace string Allows having separate locks for separate processes
Résultat boolean

unlock() public méthode

Unlocks mutex
public unlock ( string $namespace ) : void
$namespace string Namespace to use for the database table
Résultat void