6
6
use Illuminate \Console \Application as ConsoleApplication ;
7
7
use Illuminate \Console \Scheduling \Event as SchedulingEvent ;
8
8
use Illuminate \Contracts \Cache \Factory as Cache ;
9
+ use Illuminate \Contracts \Cache \Repository ;
9
10
use Illuminate \Support \Str ;
10
11
use RuntimeException ;
11
12
use Sentry \CheckIn ;
17
18
18
19
class ConsoleSchedulingIntegration extends Feature
19
20
{
21
+ /**
22
+ * @var string|null
23
+ */
24
+ private $ cacheStore = null ;
25
+
20
26
/**
21
27
* @var array<string, CheckIn> The list of checkins that are currently in progress.
22
28
*/
@@ -109,6 +115,11 @@ public function onBootInactive(): void
109
115
$ this ->shouldHandleCheckIn = false ;
110
116
}
111
117
118
+ public function useCacheStore (?string $ name ): void
119
+ {
120
+ $ this ->cacheStore = $ name ;
121
+ }
122
+
112
123
private function startCheckIn (
113
124
?string $ slug ,
114
125
SchedulingEvent $ scheduled ,
@@ -148,7 +159,7 @@ private function startCheckIn(
148
159
$ this ->checkInStore [$ cacheKey ] = $ checkIn ;
149
160
150
161
if ($ scheduled ->runInBackground ) {
151
- $ this ->resolveCache ()->store ()-> put ($ cacheKey , $ checkIn ->getId (), $ scheduled ->expiresAt * 60 );
162
+ $ this ->resolveCache ()->put ($ cacheKey , $ checkIn ->getId (), $ scheduled ->expiresAt * 60 );
152
163
}
153
164
154
165
$ this ->sendCheckIn ($ checkIn );
@@ -169,7 +180,7 @@ private function finishCheckIn(?string $slug, SchedulingEvent $scheduled, CheckI
169
180
$ checkIn = $ this ->checkInStore [$ cacheKey ] ?? null ;
170
181
171
182
if ($ checkIn === null && $ scheduled ->runInBackground ) {
172
- $ checkInId = $ this ->resolveCache ()->store ()-> get ($ cacheKey );
183
+ $ checkInId = $ this ->resolveCache ()->get ($ cacheKey );
173
184
174
185
if ($ checkInId !== null ) {
175
186
$ checkIn = $ this ->createCheckIn ($ checkInSlug , $ status , $ checkInId );
@@ -185,7 +196,7 @@ private function finishCheckIn(?string $slug, SchedulingEvent $scheduled, CheckI
185
196
unset($ this ->checkInStore [$ mutex ]);
186
197
187
198
if ($ scheduled ->runInBackground ) {
188
- $ this ->resolveCache ()->store ()-> forget ($ cacheKey );
199
+ $ this ->resolveCache ()->forget ($ cacheKey );
189
200
}
190
201
191
202
$ checkIn ->setStatus ($ status );
@@ -237,8 +248,8 @@ private function makeSlugForScheduled(SchedulingEvent $scheduled): string
237
248
return "scheduled_ {$ generatedSlug }" ;
238
249
}
239
250
240
- private function resolveCache (): Cache
251
+ private function resolveCache (): Repository
241
252
{
242
- return $ this ->container ()->make (Cache::class);
253
+ return $ this ->container ()->make (Cache::class)-> store ( $ this -> cacheStore ) ;
243
254
}
244
255
}
0 commit comments