class db

Database locking class

Methods

__construct(string $config_name, config $config, driver_interface $db)

Creates a named released instance of the lock.

bool
acquire()

Tries to acquire the lock by updating the configuration variable in the database.

bool
owns_lock()

Does this process own the lock?

null
release()

Releases the lock.

Details

at line 61
__construct(string $config_name, config $config, driver_interface $db)

Creates a named released instance of the lock.

You have to call acquire() to actually create the lock.

Parameters

string $config_name

A config variable to be used for locking

config $config

The phpBB configuration

driver_interface $db

A database connection

at line 80
bool acquire()

Tries to acquire the lock by updating the configuration variable in the database.

As a lock may only be held by one process at a time, lock acquisition may fail if another process is holding the lock or if another process obtained the lock but never released it. Locks are forcibly released after a timeout of 1 hour.

Return Value

bool

true if lock was acquired false otherwise

at line 129
bool owns_lock()

Does this process own the lock?

Return Value

bool

true if lock is owned false otherwise

at line 145
null release()

Releases the lock.

The lock must have been previously obtained, that is, acquire() call was issued and returned true.

Note: Attempting to release a lock that is already released, that is, calling release() multiple times, is harmless.

Return Value

null