interface LockBackendInterface (View source)

Lock backend interface.

Methods

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

Acquires a lock.

bool
lockMayBeAvailable(string $name)

Checks if a lock is available for acquiring.

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

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

release(string $name)

Releases the given lock.

releaseAll(string $lockId = NULL)

Releases all locks for the given lock token identifier.

string
getLockId()

Gets the unique page token for locks.

Details

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

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.

release(string $name)

Releases the given lock.

Parameters

string $name

The lock name.

releaseAll(string $lockId = NULL)

Releases all locks for the given lock token identifier.

Parameters

string $lockId

(optional) If none given, remove all locks from the current page. Defaults to NULL.

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