Skip to content

[9.x] Document WithoutOverlapping::shareKey() #8240

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,36 @@ The `WithoutOverlapping` middleware is powered by Laravel's atomic lock feature.
return [(new WithoutOverlapping($this->order->id))->expireAfter(180)];
}

By default, `WithoutOverlapping` will ensure that jobs of the same class that have a shared key do not overlap. If you want `WithoutOverlapping` to apply across different job classes, you should ensure both jobs use the same key use the `shareKey()` method:

use Illuminate\Queue\Middleware\WithoutOverlapping;

class ProviderIsDown
{
// ...


public function middleware()
{
return [
(new WithoutOverlapping("provider-status:{$this->provider}"))->shareKey(),
];
}
}

class ProviderIsUp
{
// ...


public function middleware()
{
return [
(new WithoutOverlapping("provider-status:{$this->provider}"))->shareKey(),
];
}
}

> **Warning**
> The `WithoutOverlapping` middleware requires a cache driver that supports [locks](/docs/{{version}}/cache#atomic-locks). Currently, the `memcached`, `redis`, `dynamodb`, `database`, `file`, and `array` cache drivers support atomic locks.

Expand Down