See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 401] [Versions 401 and 403]
Defines abstract factory class for generating locks.
Copyright: | Damyon Wiese 2013 |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 108 lines (4 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
lock_factory:: (8 methods):
__construct()
supports_timeout()
supports_auto_release()
supports_recursion()
is_available()
get_lock()
release_lock()
extend_lock()
Interface: lock_factory - X-Ref
Defines abstract factory class for generating locks.__construct($type) X-Ref |
Define the constructor signature required by the lock_config class. param: string $type - The type this lock is used for (e.g. cron, cache) |
supports_timeout() X-Ref |
Return information about the blocking behaviour of the locks on this platform. return: boolean - False if attempting to get a lock will block indefinitely. |
supports_auto_release() X-Ref |
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. return: boolean - True if this lock type will be automatically released when the current process ends. |
supports_recursion() X-Ref |
Supports recursion. return: boolean - True if attempting to get 2 locks on the same resource will "stack" |
is_available() X-Ref |
Is available. return: boolean - True if this lock type is available in this environment. |
get_lock($resource, $timeout, $maxlifetime = 86400) X-Ref |
Get a lock within the specified timeout or return false. param: string $resource - The identifier for the lock. Should use frankenstyle prefix. param: int $timeout - The number of seconds to wait for a lock before giving up. param: int $maxlifetime - The number of seconds to wait before reclaiming a stale lock. return: \core\lock\lock|boolean - An instance of \core\lock\lock if the lock was obtained, or false. |
release_lock(lock $lock) X-Ref |
Release a lock that was previously obtained with @lock. param: lock $lock - The lock to release. return: boolean - True if the lock is no longer held (including if it was never held). |
extend_lock(lock $lock, $maxlifetime = 86400) X-Ref |
Extend the timeout on a held lock. param: lock $lock - lock obtained from this factory param: int $maxlifetime - new max time to hold the lock return: boolean - True if the lock was extended. |