-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename overlapping strategy to mutex
- Loading branch information
1 parent
b42274b
commit ae2eb1f
Showing
12 changed files
with
172 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Illuminate\Console\Scheduling; | ||
|
||
use Illuminate\Contracts\Cache\Repository as Cache; | ||
|
||
class CacheMutex implements Mutex | ||
{ | ||
/** | ||
* The cache repository implementation. | ||
* | ||
* @var \Illuminate\Contracts\Cache\Repository | ||
*/ | ||
public $cache; | ||
|
||
/** | ||
* Create a new overlapping strategy. | ||
* | ||
* @param \Illuminate\Contracts\Cache\Repository $cache | ||
* @return void | ||
*/ | ||
public function __construct(Cache $cache) | ||
{ | ||
$this->cache = $cache; | ||
} | ||
|
||
/** | ||
* Attempt to obtain a mutex for the given event. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Event $event | ||
* @return bool | ||
*/ | ||
public function create(Event $event) | ||
{ | ||
return $this->cache->add($event->mutexName(), true, 1440); | ||
} | ||
|
||
/** | ||
* Determine if a mutex exists for the given event. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Event $event | ||
* @return bool | ||
*/ | ||
public function exists(Event $event) | ||
{ | ||
return $this->cache->has($event->mutexName()); | ||
} | ||
|
||
/** | ||
* Clear the mutex for the given event. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Event $event | ||
* @return void | ||
*/ | ||
public function forget(Event $event) | ||
{ | ||
$this->cache->forget($event->mutexName()); | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
src/Illuminate/Console/Scheduling/CacheOverlappingStrategy.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Illuminate\Console\Scheduling; | ||
|
||
interface Mutex | ||
{ | ||
/** | ||
* Attempt to obtain a mutex for the given event. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Event $event | ||
* @return bool | ||
*/ | ||
public function create(Event $event); | ||
|
||
/** | ||
* Determine if a mutex exists for the given event. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Event $event | ||
* @return bool | ||
*/ | ||
public function exists(Event $event); | ||
|
||
/** | ||
* Clear the mutex for the given event. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Event $event | ||
* @return void | ||
*/ | ||
public function forget(Event $event); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.