CacheLock
class CacheLock extends Lock
Traits
Properties
| protected string | $name | The name of the lock. |
from Lock |
| protected int | $seconds | The number of seconds the lock should be maintained. |
from Lock |
| protected string | $owner | The scope identifier of this lock. |
from Lock |
| protected int | $sleepMilliseconds | The number of milliseconds to wait before re-attempting to acquire a lock while blocking. |
from Lock |
| protected Store | $store | The cache store implementation. |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Create a new lock instance.
Attempt to acquire the lock.
Release the lock.
Returns the owner value written into the driver for this lock.
Attempt to acquire the lock for the given number of seconds.
Attempt to refresh the lock for the given number of seconds.
Determine whether this lock is allowed to release the lock in the driver.
Determine whether this lock is owned by the given identifier.
Specify the number of milliseconds to sleep in between blocked lock acquisition attempts.
Releases this lock regardless of ownership.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 47
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 63
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 71
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
at line 19
__construct(Store $store, string $name, int $seconds, string|null $owner = null)
Create a new lock instance.
at line 29
bool
acquire()
Attempt to acquire the lock.
at line 51
bool
release()
Release the lock.
at line 71
protected string|null
getCurrentOwner()
Returns the owner value written into the driver for this lock.
in
Lock at line 73
mixed
get(callable|null $callback = null)
Attempt to acquire the lock.
in
Lock at line 95
mixed
block(int $seconds, callable|null $callback = null)
Attempt to acquire the lock for the given number of seconds.
in
Lock at line 129
protected never
releaseAfterFailure(Throwable $failure)
Release the lock while preserving the primary failure.
in
Lock at line 149
bool
refresh(int|null $seconds = null)
Attempt to refresh the lock for the given number of seconds.
in
Lock at line 159
float|null
getRemainingLifetime()
Get the number of seconds until the lock expires.
in
Lock at line 167
string
owner()
Return the current owner of the lock.
in
Lock at line 175
bool
isLocked()
Determine if the lock is currently held by any process.
in
Lock at line 183
bool
isOwnedByCurrentProcess()
Determine whether this lock is allowed to release the lock in the driver.
in
Lock at line 191
bool
isOwnedBy(string|null $owner)
Determine whether this lock is owned by the given identifier.
in
Lock at line 199
Lock
betweenBlockedAttemptsSleepFor(int $milliseconds)
Specify the number of milliseconds to sleep in between blocked lock acquisition attempts.
at line 63
void
forceRelease()
Releases this lock regardless of ownership.