class DatabaseLockBackend implements LockBackendInterface (View source)

Provides a proxy class for \Drupal\Core\Lock\DatabaseLockBackend.

Traits

Provides dependency injection friendly methods for serialization.

Properties

protected array $_serviceIds

An array of service IDs keyed by property name used for serialization.

from  DependencySerializationTrait
protected array $_entityStorages

An array of entity type IDs keyed by the property name of their storages.

from  DependencySerializationTrait
protected string $drupalProxyOriginalServiceId

The id of the original proxied service.

protected DatabaseLockBackend $service

The real proxied service, after it was lazy loaded.

protected ContainerInterface $container

The service container.

Methods

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

__construct(ContainerInterface $container, string $drupal_proxy_original_service_id)

Constructs a ProxyClass Drupal proxy object.

object
lazyLoadItself()

Lazy loads the real service from the container.

bool
acquire(string $name, float $timeout = 30.0)

Acquires a lock.

bool
lockMayBeAvailable(string $name)

Checks if a lock is available for acquiring.

release(string $name)

Releases the given lock.

releaseAll($lock_id = NULL)

Releases all locks for the given lock token identifier.

schemaDefinition()

{@inheritdoc}

bool
wait(string $name, int $delay = 30)

Waits a short amount of time before a second lock acquire attempt.

string
getLockId()

Gets the unique page token for locks.

Details

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

__construct(ContainerInterface $container, string $drupal_proxy_original_service_id)

Constructs a ProxyClass Drupal proxy object.

Parameters

ContainerInterface $container

The container.

string $drupal_proxy_original_service_id

The service ID of the original service.

protected object lazyLoadItself()

Lazy loads the real service from the container.

Return Value

object

Returns the constructed real service.

bool acquire(string $name, float $timeout = 30.0)

Acquires a lock.

Parameters

string $name

Lock name. Limit of name's length is 255 characters.

float $timeout

(optional) Lock lifetime in seconds. Defaults to 30.0.

Return Value

bool

bool lockMayBeAvailable(string $name)

Checks if a lock is available for acquiring.

Parameters

string $name

Lock to acquire.

Return Value

bool

release(string $name)

Releases the given lock.

Parameters

string $name

The lock name.

releaseAll($lock_id = NULL)

Releases all locks for the given lock token identifier.

Parameters

$lock_id

schemaDefinition()

{@inheritdoc}

bool wait(string $name, int $delay = 30)

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.

Parameters

string $name

Lock name currently being locked.

int $delay

Seconds to wait for. Defaults to 30.

Return Value

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.

string getLockId()

Gets the unique page token for locks.

Locks will be wiped out at the end of each page request on a token basis.

Return Value

string