WithoutOverlapping
class WithoutOverlapping (View source)
Traits
Properties
string | $key | The job's unique key used for preventing overlaps. |
|
DateTimeInterface|int|null | $releaseAfter | The number of seconds before a job should be available again if no lock was acquired. |
|
int | $expiresAfter | The number of seconds before the lock should expire. |
|
string | $prefix | The prefix of the lock key. |
|
bool | $shareKey | Share the key across different jobs. |
Methods
Get the number of seconds until the given DateTime.
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 middleware instance.
Process the job.
Set the delay (in seconds) to release the job back to the queue.
Do not release the job back to the queue if no lock can be acquired.
Set the maximum number of seconds that can elapse before the lock is released.
Set the prefix of the lock key.
Indicate that the lock key should be shared across job classes.
Get the lock key for the given job.
Details
protected int
secondsUntil(DateTimeInterface|DateInterval|int $delay)
Get the number of seconds until the given DateTime.
protected int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)
Get the "available at" UNIX timestamp.
protected DateTimeInterface|int
parseDateInterval(DateTimeInterface|DateInterval|int $delay)
If the given value is an interval, convert it to a DateTime instance.
protected int
currentTime()
Get the current system time as a UNIX timestamp.
protected string
runTimeForHumans(float $startTime, float $endTime = null)
Given a start time, format the total run time for human readability.
void
__construct(string $key = '', DateTimeInterface|int|null $releaseAfter = 0, DateTimeInterface|int $expiresAfter = 0)
Create a new middleware instance.
mixed
handle(mixed $job, callable $next)
Process the job.
$this
releaseAfter(DateTimeInterface|int $releaseAfter)
Set the delay (in seconds) to release the job back to the queue.
$this
dontRelease()
Do not release the job back to the queue if no lock can be acquired.
$this
expireAfter(DateTimeInterface|DateInterval|int $expiresAfter)
Set the maximum number of seconds that can elapse before the lock is released.
$this
withPrefix(string $prefix)
Set the prefix of the lock key.
$this
shared()
Indicate that the lock key should be shared across job classes.
string
getLockKey(mixed $job)
Get the lock key for the given job.