API / Minn\Runtime / OptionLock

OptionLock final class

Minn\Runtime\OptionLock · public/minn/src/Minn/Runtime/OptionLock.php · 23 lines

A lock the reference keeps as an option row (the revision upgrade's "revision-upgrade-{id}", the comment type batch's "update_comment_type.lock"; tests/tools/side-effects.php): inserted only when no row holds the name, its value the time it was taken; one held for less than an hour keeps others out, an older one is taken over. The holder writes the time again through update_option, and deletes the row when done.

Constants and properties

privateHELD_SECONDS = 3600

How long a held lock keeps others out, in seconds.

Public

statictake(string $name, string $autoload): bool#

Takes the lock, inserting its row with the autoload value the reference gives it; false while another holds it.

staticrelease(string $name): void#

Lets the lock go.