toolkit

Lock

Exclusive file locks that serialize work across PHP processes on one host.

Site code uses $app->lock($key, $fn), which picks the lock file and turns a timeout into a 503.

Lock:: Phlat\Toolkit\Lock 1 methods

Locking 1

  • run Runs $fn holding an exclusive lock on $file, creating it if needed, and returns its result.

Locking

run

Lock::run(string $file, callable $fn, float $timeout = 10): mixed

Runs $fn holding an exclusive lock on $file, creating it if needed, and returns its result.

Re-entrant: a nested call on a file this process already holds joins it. Waits up to $timeout seconds (0 tries once) before throwing LockTimeout.

Parameters (3)
$file string
$fn callable
$timeout float = 10

Returns mixed

phlat/src/Toolkit/Lock.php:28