interface LockBackendInterface

Same name in other branches
  1. 9 core/lib/Drupal/Core/Lock/LockBackendInterface.php \Drupal\Core\Lock\LockBackendInterface
  2. 8.9.x core/lib/Drupal/Core/Lock/LockBackendInterface.php \Drupal\Core\Lock\LockBackendInterface
  3. 10 core/lib/Drupal/Core/Lock/LockBackendInterface.php \Drupal\Core\Lock\LockBackendInterface

Lock backend interface.

Hierarchy

Expanded class hierarchy of LockBackendInterface

All classes that implement LockBackendInterface

Related topics

33 files declare their use of LockBackendInterface
AliasPrefixList.php in core/modules/path_alias/src/AliasPrefixList.php
BlockContentUuidLookup.php in core/modules/block_content/src/BlockContentUuidLookup.php
BrokenSystemTestController.php in core/modules/system/tests/modules/system_test/src/Controller/BrokenSystemTestController.php
CacheCollector.php in core/lib/Drupal/Core/Cache/CacheCollector.php
CKEditor5ImageController.php in core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php

... See full list

File

core/lib/Drupal/Core/Lock/LockBackendInterface.php, line 83

Namespace

Drupal\Core\Lock
View source
interface LockBackendInterface {
    
    /**
     * Acquires a lock.
     *
     * @param string $name
     *   Lock name. Limit of name's length is 255 characters.
     * @param float $timeout
     *   (optional) Lock lifetime in seconds. Defaults to 30.0.
     *
     * @return bool
     */
    public function acquire($name, $timeout = 30.0);
    
    /**
     * Checks if a lock is available for acquiring.
     *
     * @param string $name
     *   Lock to acquire.
     *
     * @return bool
     */
    public function lockMayBeAvailable($name);
    
    /**
     * Waits a short amount of time before a second lock acquire attempt.
     *
     * While this method is subject to have a generic implementation in abstract
     * backend implementation, some backends may provide non blocking or less I/O
     * intensive wait mechanism: this is why this method remains on the backend
     * interface.
     *
     * @param string $name
     *   Lock name currently being locked.
     * @param int $delay
     *   Seconds to wait for. Defaults to 30.
     *
     * @return bool
     *   TRUE if the lock holds, FALSE if it may be available. You still need to
     *   acquire the lock manually and it may fail again.
     */
    public function wait($name, $delay = 30);
    
    /**
     * Releases the given lock.
     *
     * @param string $name
     *   The lock name.
     */
    public function release($name);
    
    /**
     * Releases all locks for the given lock token identifier.
     *
     * @param string $lockId
     *   (optional) If none given, remove all locks from the current page.
     *   Defaults to NULL.
     */
    public function releaseAll($lockId = NULL);
    
    /**
     * Gets the unique page token for locks.
     *
     * Locks will be wiped out at the end of each page request on a token basis.
     *
     * @return string
     */
    public function getLockId();

}

Members

Title Sort descending Modifiers Object type Summary Overrides
LockBackendInterface::acquire public function Acquires a lock. 5
LockBackendInterface::getLockId public function Gets the unique page token for locks. 4
LockBackendInterface::lockMayBeAvailable public function Checks if a lock is available for acquiring. 5
LockBackendInterface::release public function Releases the given lock. 5
LockBackendInterface::releaseAll public function Releases all locks for the given lock token identifier. 5
LockBackendInterface::wait public function Waits a short amount of time before a second lock acquire attempt. 4

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.