LockManager
in package
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
$rules
private
mixed
$rules
= []
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
Return values
LockInterfacecreate()
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
Return values
LockInterfacegetFactory()
public
getFactory(string $name) : callable|null
Parameters
- $name : string
-
Symbolic name for the lock.
Return values
callable|nullregister()
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.