Skip to content

Commit 965d77e

Browse files
committed
dont use locks when using dynamo
1 parent 5deb049 commit 965d77e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Illuminate/Console/Scheduling/CacheEventMutex.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Console\Scheduling;
44

5+
use Illuminate\Cache\DynamoDbStore;
56
use Illuminate\Contracts\Cache\Factory as Cache;
67
use Illuminate\Contracts\Cache\LockProvider;
78

@@ -40,7 +41,7 @@ public function __construct(Cache $cache)
4041
*/
4142
public function create(Event $event)
4243
{
43-
if ($this->cache->store($this->store)->getStore() instanceof LockProvider) {
44+
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
4445
return $this->cache->store($this->store)->getStore()
4546
->lock($event->mutexName(), $event->expiresAt * 60)
4647
->acquire();
@@ -59,7 +60,7 @@ public function create(Event $event)
5960
*/
6061
public function exists(Event $event)
6162
{
62-
if ($this->cache->store($this->store)->getStore() instanceof LockProvider) {
63+
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
6364
return ! $this->cache->store($this->store)->getStore()
6465
->lock($event->mutexName(), $event->expiresAt * 60)
6566
->get(fn () => true);
@@ -76,7 +77,7 @@ public function exists(Event $event)
7677
*/
7778
public function forget(Event $event)
7879
{
79-
if ($this->cache->store($this->store)->getStore() instanceof LockProvider) {
80+
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
8081
$this->cache->store($this->store)->getStore()
8182
->lock($event->mutexName(), $event->expiresAt * 60)
8283
->forceRelease();
@@ -87,6 +88,17 @@ public function forget(Event $event)
8788
$this->cache->store($this->store)->forget($event->mutexName());
8889
}
8990

91+
/**
92+
* Determine if the given store should use locks for cache event mutexes.
93+
*
94+
* @param \Illuminate\Contracts\Cache\Store $store
95+
* @return bool
96+
*/
97+
protected function shouldUseLocks($store)
98+
{
99+
return $store instanceof LockProvider && ! $store instanceof DynamoDbStore;
100+
}
101+
90102
/**
91103
* Specify the cache store that should be used.
92104
*

0 commit comments

Comments
 (0)