Skip to content

Commit cd1bbe9

Browse files
author
Andrey Helldar
authored
Added the ability to use the uniqueFor method for Jobs (#40974)
1 parent 5a4722e commit cd1bbe9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Illuminate/Bus/UniqueLock.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ public function acquire($job)
3636
? $job->uniqueId()
3737
: ($job->uniqueId ?? '');
3838

39+
$uniqueFor = method_exists($job, 'uniqueFor')
40+
? $job->uniqueFor()
41+
: ($job->uniqueFor ?? 0);
42+
3943
$cache = method_exists($job, 'uniqueVia')
4044
? $job->uniqueVia()
4145
: $this->cache;
4246

4347
return (bool) $cache->lock(
4448
$key = 'laravel_unique_job:'.get_class($job).$uniqueId,
45-
$job->uniqueFor ?? 0
49+
$uniqueFor
4650
)->get();
4751
}
4852
}

0 commit comments

Comments
 (0)