Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Added the ability to use the uniqueFor method for Jobs #40974

Merged
merged 1 commit into from
Feb 12, 2022

Conversation

andrey-helldar
Copy link
Contributor

Currently, you can specify the duration of the job uniqueness check either by explicitly specifying the value in the variable, or by creating your own method, for example:

public function __constructor()
{
    $this->uniqueFor = $this->uniqueFor();
}

protected function uniqueFor()
{
    return now()->diffInRealSeconds($this->delay);
}

In my case, the job is created with a delayed start and there is a need to check the uniqueness during this time.

This means that you need to dynamically calculate the duration.

By adding the ability to use the "uniqueFor" method like the "uniqueId" method, we reduce the amount of code:

protected function uniqueFor()
{
    return now()->diffInRealSeconds($this->delay);
}

This will allow more flexible control over the uniqueness time.

@andrey-helldar andrey-helldar changed the title Added the ability to use the uniqueFor method for Jobs [9.x] Added the ability to use the uniqueFor method for Jobs Feb 12, 2022
@taylorotwell taylorotwell merged commit cd1bbe9 into laravel:9.x Feb 12, 2022
@andrey-helldar andrey-helldar deleted the patch/2022-02-12/13-08 branch February 12, 2022 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants