Documentation

LockManager

Class LockManager

Table of Contents

Properties

$rules  : mixed

Methods

acquire()  : LockInterface
Create and attempt to acquire a lock.
create()  : LockInterface
getFactory()  : callable|null
register()  : LockManager
Register the lock-factory to use for specific lock-names.

Properties

Methods

acquire()

Create and attempt to acquire a lock.

public acquire(string $name[, int|null $timeout = NULL ]) : LockInterface

Note: Be sure to check $lock->isAcquired() to determine whether acquisition was successful.

Parameters
$name : string

Symbolic name for the lock. Names generally look like "worker.mailing.EmailProcessor" ("{category}.{component}.{AdhocName}").

Categories: worker|data|cache|... Component: core|mailing|member|contribute|...

$timeout : int|null = NULL

The number of seconds to wait to get the lock. For a default value, use NULL.

Tags
throws
CRM_Core_Exception
Return values
LockInterface

create()

public create(string $name) : LockInterface
Parameters
$name : string

Symbolic name for the lock. Names generally look like "worker.mailing.EmailProcessor" ("{category}.{component}.{AdhocName}").

Categories: worker|data|cache|... Component: core|mailing|member|contribute|...

Tags
throws
CRM_Core_Exception
Return values
LockInterface

getFactory()

public getFactory(string $name) : callable|null
Parameters
$name : string

Symbolic name for the lock.

Return values
callable|null

register()

Register the lock-factory to use for specific lock-names.

public register(string $pattern, string|array<string|int, mixed> $factory) : LockManager
Parameters
$pattern : string

A regex to match against the lock name.

$factory : string|array<string|int, mixed>

A callback. The callback should accept a $name parameter. Callbacks will be located using the resolver.

Tags
see
Resolver
Return values
LockManager

        
On this page

Search results