2
2
3
3
namespace Illuminate \Console \Scheduling ;
4
4
5
+ use Illuminate \Cache \DynamoDbStore ;
5
6
use Illuminate \Contracts \Cache \Factory as Cache ;
6
7
use Illuminate \Contracts \Cache \LockProvider ;
7
8
@@ -40,7 +41,7 @@ public function __construct(Cache $cache)
40
41
*/
41
42
public function create (Event $ event )
42
43
{
43
- if ($ this ->cache ->store ($ this ->store )->getStore () instanceof LockProvider ) {
44
+ if ($ this ->shouldUseLocks ( $ this -> cache ->store ($ this ->store )->getStore ()) ) {
44
45
return $ this ->cache ->store ($ this ->store )->getStore ()
45
46
->lock ($ event ->mutexName (), $ event ->expiresAt * 60 )
46
47
->acquire ();
@@ -59,7 +60,7 @@ public function create(Event $event)
59
60
*/
60
61
public function exists (Event $ event )
61
62
{
62
- if ($ this ->cache ->store ($ this ->store )->getStore () instanceof LockProvider ) {
63
+ if ($ this ->shouldUseLocks ( $ this -> cache ->store ($ this ->store )->getStore ()) ) {
63
64
return ! $ this ->cache ->store ($ this ->store )->getStore ()
64
65
->lock ($ event ->mutexName (), $ event ->expiresAt * 60 )
65
66
->get (fn () => true );
@@ -76,7 +77,7 @@ public function exists(Event $event)
76
77
*/
77
78
public function forget (Event $ event )
78
79
{
79
- if ($ this ->cache ->store ($ this ->store )->getStore () instanceof LockProvider ) {
80
+ if ($ this ->shouldUseLocks ( $ this -> cache ->store ($ this ->store )->getStore ()) ) {
80
81
$ this ->cache ->store ($ this ->store )->getStore ()
81
82
->lock ($ event ->mutexName (), $ event ->expiresAt * 60 )
82
83
->forceRelease ();
@@ -87,6 +88,17 @@ public function forget(Event $event)
87
88
$ this ->cache ->store ($ this ->store )->forget ($ event ->mutexName ());
88
89
}
89
90
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
+
90
102
/**
91
103
* Specify the cache store that should be used.
92
104
*
0 commit comments