Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Public Member Functions | |
__construct ($type) | |
Define the constructor signature required by the lock_config class. More... | |
extend_lock (lock $lock, $maxlifetime=86400) | |
Extend the timeout on a held lock. More... | |
get_lock ($resource, $timeout, $maxlifetime=86400) | |
Get a lock within the specified timeout or return false. More... | |
is_available () | |
Is available. More... | |
release_lock (lock $lock) | |
Release a lock that was previously obtained with @lock. More... | |
supports_auto_release () | |
Will this lock be automatically released when the process ends. More... | |
supports_recursion () | |
Supports recursion. More... | |
supports_timeout () | |
Return information about the blocking behaviour of the locks on this platform. More... | |
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\file_lock_factory, core\lock\installation_lock_factory, core\lock\mysql_lock_factory, and core\lock\postgres_lock_factory.
core\lock\lock_factory::extend_lock | ( | lock | $lock, |
$maxlifetime = 86400 |
|||
) |
Extend the timeout on a held lock.
lock | $lock | - lock obtained from this factory |
int | $maxlifetime | - new max time to hold the lock |
boolean | - True if the lock was extended. |
Implemented in core\lock\db_record_lock_factory, core\lock\file_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, and core\lock\postgres_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, and core\lock\postgres_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, and core\lock\postgres_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, and core\lock\postgres_lock_factory.
core\lock\lock_factory::supports_recursion | ( | ) |
Supports recursion.
boolean | - True if attempting to get 2 locks on the same resource will "stack" |
Implemented in core\lock\db_record_lock_factory, core\lock\file_lock_factory, core\lock\installation_lock_factory, core\lock\mysql_lock_factory, and core\lock\postgres_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, and core\lock\postgres_lock_factory.