Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Public Member Functions | |
__construct ($name, array $configuration=array()) | |
Constructs an instance of the cache lock given its name and its configuration data. | |
__destruct () | |
Cleans up any left over locks. | |
check_state ($key, $ownerid) | |
Checks the state of the given key. | |
lock ($key, $ownerid, $block=false) | |
Acquires a lock on a given key. | |
unlock ($key, $ownerid, $forceunlock=false) | |
Releases the lock held on a certain key. | |
Cache lock interface.
This interface needs to be inherited by all cache lock plugins.
cache_lock_interface::__construct | ( | $name, | |
array | $configuration = array() ) |
Constructs an instance of the cache lock given its name and its configuration data.
string | $name | The unique name of the lock instance |
array | $configuration |
Implemented in cachelock_file.
cache_lock_interface::__destruct | ( | ) |
Cleans up any left over locks.
This function MUST clean up any locks that have been acquired and not released during processing. Although the situation of acquiring a lock and not releasing it should be insanely rare we need to deal with it. Things such as unfortunate timeouts etc could cause this situation.
Implemented in cachelock_file.
cache_lock_interface::check_state | ( | $key, | |
$ownerid ) |
Checks the state of the given key.
Returns true if the key is locked and belongs to the ownerid. Returns false if the key is locked but does not belong to the ownerid. Returns null if there is no lock
string | $key | The key we are checking for. |
string | $ownerid | The identifier so we can check if we have the lock or if it is someone else. |
bool | True if this code has the lock, false if there is a lock but this code doesn't have it, null if there is no lock. |
Implemented in cachelock_file.
cache_lock_interface::lock | ( | $key, | |
$ownerid, | |||
$block = false ) |
Acquires a lock on a given key.
string | $key | The key to acquire a lock for. |
string | $ownerid | An unique identifier for the owner of this lock. It is entirely optional for the cache lock plugin to use this. Each implementation can decide for themselves. |
bool | $block | If set to true the application will wait until a lock can be acquired |
bool | True if the lock can be acquired false otherwise. |
Implemented in cachelock_file.
cache_lock_interface::unlock | ( | $key, | |
$ownerid, | |||
$forceunlock = false ) |
Releases the lock held on a certain key.
string | $key | The key to release the lock for. |
string | $ownerid | An unique identifier for the owner of this lock. It is entirely optional for the cache lock plugin to use this. Each implementation can decide for themselves. |
bool | $forceunlock | If set to true the lock will be removed if it exists regardless of whether or not we own it. |
Implemented in cachelock_file.