Elgg  Version 4.3
Public Member Functions | List of all members
Elgg\Database\Mutex Class Reference

Provides database mutex that can be used to prevent race conditions between two processes that affect the same data. More...

Public Member Functions

 __construct (Database $db)
 Constructor. More...
 
 lock (string $namespace)
 Creates a table {prefix}{$namespace}_lock that is used as a mutex. More...
 
 unlock (string $namespace)
 Unlocks mutex. More...
 
 isLocked (string $namespace)
 Checks if mutex is locked. More...
 

Detailed Description

Provides database mutex that can be used to prevent race conditions between two processes that affect the same data.

NOTE: This class uses the database connections directly because the queries aren't QueryBuilders

Definition at line 18 of file Mutex.php.

Constructor & Destructor Documentation

Elgg\Database\Mutex::__construct ( Database  $db)

Constructor.

Parameters
Database$dbDatabase

Definition at line 32 of file Mutex.php.

Member Function Documentation

Elgg\Database\Mutex::isLocked ( string  $namespace)

Checks if mutex is locked.

Parameters
string$namespaceNamespace to use for the database table
Returns
bool

Definition at line 80 of file Mutex.php.

Elgg\Database\Mutex::lock ( string  $namespace)

Creates a table {prefix}{$namespace}_lock that is used as a mutex.

Parameters
string$namespaceAllows having separate locks for separate processes
Returns
bool

Definition at line 43 of file Mutex.php.

Elgg\Database\Mutex::unlock ( string  $namespace)

Unlocks mutex.

Parameters
string$namespaceNamespace to use for the database table
Returns
void

Definition at line 65 of file Mutex.php.


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