From 5dfd63ea50863383e3e2b093ea4231495b8b522d Mon Sep 17 00:00:00 2001 From: zhaozhongjin <79534505@qq.com> Date: Fri, 2 Nov 2018 15:55:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3:=20=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=88=B0laravel5.5=E4=BB=A5=E4=B8=8B=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 +- src/Events/EnsureCleanUpExecuted.php | 2 +- src/Scheduling/CacheMutex.php | 61 ---------------------------- src/Scheduling/Event.php | 13 +++--- src/Scheduling/Mutex.php | 2 +- src/Scheduling/Schedule.php | 8 ++-- tests/MultiServerEventTest.php | 4 +- 7 files changed, 15 insertions(+), 78 deletions(-) delete mode 100644 src/Scheduling/CacheMutex.php diff --git a/composer.json b/composer.json index a184e62..20ae9e5 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,7 @@ ], "require": { "php": ">=5.5.9", - "laravel/framework": ">=5.1 <5.6", - "ext-pdo": "*" + "laravel/framework": ">=5.1 <=5.4" }, "autoload": { "psr-4": { diff --git a/src/Events/EnsureCleanUpExecuted.php b/src/Events/EnsureCleanUpExecuted.php index 185a233..ede1032 100644 --- a/src/Events/EnsureCleanUpExecuted.php +++ b/src/Events/EnsureCleanUpExecuted.php @@ -1,5 +1,5 @@ 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, $event->expiresAt - ); - } - - /** - * 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()); - } -} diff --git a/src/Scheduling/Event.php b/src/Scheduling/Event.php index f71436f..f3a4d66 100644 --- a/src/Scheduling/Event.php +++ b/src/Scheduling/Event.php @@ -1,11 +1,10 @@ key = $this->getKey(); $this->then(function() { $this->clearMultiserver(); diff --git a/src/Scheduling/Mutex.php b/src/Scheduling/Mutex.php index d5024e7..ad1482d 100644 --- a/src/Scheduling/Mutex.php +++ b/src/Scheduling/Mutex.php @@ -1,6 +1,6 @@ compileParameters($parameters); } - $this->events[] = $event = new Event(app()->make(CacheMutex::class), $command); + $this->events[] = $event = new Event(app()->make(Cache::class), $command); return $event; } } \ No newline at end of file diff --git a/tests/MultiServerEventTest.php b/tests/MultiServerEventTest.php index 95dadea..bf613a6 100644 --- a/tests/MultiServerEventTest.php +++ b/tests/MultiServerEventTest.php @@ -9,8 +9,8 @@ class MultiServerEventTest extends TestCase { */ public function it_initializes_the_schedule() { - $schedule = new feeloho\MultiServerEvent\Scheduling\Schedule(app()[Illuminate\Contracts\Cache\Repository::class]); - $this->assertTrue($schedule instanceof feeloho\MultiServerEvent\Scheduling\Schedule); + $schedule = new Feeloho\MultiServerEvent\Scheduling\Schedule(app()[Illuminate\Contracts\Cache\Repository::class]); + $this->assertTrue($schedule instanceof Feeloho\MultiServerEvent\Scheduling\Schedule); $result = $schedule->command('inspire') ->daily()