Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Defines abstract factory class for generating locks. More...
Public Member Functions | |
__construct ($type) | |
Define the constructor signature required by the lock_config class. | |
get_lock ($resource, $timeout, $maxlifetime=86400) | |
Get a lock within the specified timeout or return false. | |
is_available () | |
Is available. | |
release_lock (lock $lock) | |
Release a lock that was previously obtained with @lock. | |
supports_auto_release () | |
Will this lock be automatically released when the process ends. | |
supports_timeout () | |
Return information about the blocking behaviour of the locks on this platform. | |
Defines abstract factory class for generating locks.
core\lock\lock_factory::__construct | ( | $type | ) |
Define the constructor signature required by the lock_config class.
string | $type | - The type this lock is used for (e.g. cron, cache) |
Implemented in core\lock\db_record_lock_factory, core\lock\installation_lock_factory, core\lock\mysql_lock_factory, and core\lock\postgres_lock_factory.
core\lock\lock_factory::get_lock | ( | $resource, | |
$timeout, | |||
$maxlifetime = 86400 ) |
Get a lock within the specified timeout or return false.
string | $resource | - The identifier for the lock. Should use frankenstyle prefix. |
int | $timeout | - The number of seconds to wait for a lock before giving up. Not all lock types will support this. |
int | $maxlifetime | - The number of seconds to wait before reclaiming a stale lock. Not all lock types will use this - e.g. if they support auto releasing a lock when a process ends. |
core\lock\lock|boolean | - An instance of core\lock\lock if the lock was obtained, or false. |
Implemented in core\lock\db_record_lock_factory, core\lock\file_lock_factory, core\lock\installation_lock_factory, core\lock\mysql_lock_factory, core\lock\postgres_lock_factory, and core\lock\timing_wrapper_lock_factory.
core\lock\lock_factory::is_available | ( | ) |
Is available.
boolean | - True if this lock type is available in this environment. |
Implemented in core\lock\db_record_lock_factory, core\lock\file_lock_factory, core\lock\installation_lock_factory, core\lock\mysql_lock_factory, core\lock\postgres_lock_factory, and core\lock\timing_wrapper_lock_factory.
core\lock\lock_factory::release_lock | ( | lock | $lock | ) |
Release a lock that was previously obtained with @lock.
lock | $lock | - The lock to release. |
boolean | - True if the lock is no longer held (including if it was never held). |
Implemented in core\lock\db_record_lock_factory, core\lock\file_lock_factory, core\lock\installation_lock_factory, core\lock\mysql_lock_factory, core\lock\postgres_lock_factory, and core\lock\timing_wrapper_lock_factory.
core\lock\lock_factory::supports_auto_release | ( | ) |
Will this lock be automatically released when the process ends.
This should never be relied upon in code - but is useful in the case of fatal errors. If a lock type does not support this auto release, the max lock time parameter must be obeyed to eventually clean up a lock.
boolean | - True if this lock type will be automatically released when the current process ends. |
Implemented in core\lock\db_record_lock_factory, core\lock\file_lock_factory, core\lock\installation_lock_factory, core\lock\mysql_lock_factory, core\lock\postgres_lock_factory, and core\lock\timing_wrapper_lock_factory.
core\lock\lock_factory::supports_timeout | ( | ) |
Return information about the blocking behaviour of the locks on this platform.
boolean | - False if attempting to get a lock will block indefinitely. |
Implemented in core\lock\db_record_lock_factory, core\lock\file_lock_factory, core\lock\installation_lock_factory, core\lock\mysql_lock_factory, core\lock\postgres_lock_factory, and core\lock\timing_wrapper_lock_factory.