@@ -59,6 +59,16 @@ private function getStoreFromConnectionName(string $connection_name): ?string
59
59
return null ;
60
60
}
61
61
62
+ protected function getCache_invalidation_eventsPartitionName (int $ shardId , int $ priority , int $ processed , Carbon $ processingStartTime ): string
63
+ {
64
+ if ($ processed === 0 ) {
65
+ return "p_unprocessed_s {$ shardId }_p {$ priority }" ;
66
+ }
67
+ $ year = $ processingStartTime ->year ;
68
+ $ week = $ processingStartTime ->weekOfYear ;
69
+ return "p_s {$ shardId }_p {$ priority }_ {$ year }w {$ week }" ;
70
+ }
71
+
62
72
/**
63
73
* Process cache invalidation events.
64
74
*
@@ -75,7 +85,9 @@ protected function processEvents(int $shardId, int $priority, int $limit, int $t
75
85
$ invalidationWindow = config ('super_cache_invalidate.invalidation_window ' );
76
86
77
87
// Fetch a batch of unprocessed events
78
- $ events = DB ::table ('cache_invalidation_events ' )
88
+ $ partitionCache_invalidation_events = $ this ->getCache_invalidation_eventsPartitionName ($ shardId , $ priority , 0 , $ processingStartTime );
89
+ $ events = DB ::table (DB ::raw ("`cache_invalidation_events` PARTITION ( {$ partitionCache_invalidation_events }) " ))
90
+ //->from(DB::raw("`{$this->from}` PARTITION ({$partitionsString})"))
79
91
->where ('processed ' , '= ' , 0 )
80
92
->where ('shard ' , '= ' , $ shardId )
81
93
->where ('priority ' , '= ' , $ priority )
@@ -106,7 +118,8 @@ protected function processEvents(int $shardId, int $priority, int $limit, int $t
106
118
107
119
//retrive associated identifiers related to fetched event id
108
120
// Per le chiavi/tag associati non filtro per connection_name, potrebbero esserci associazioni anche in altri database
109
- $ associations = DB ::table ('cache_invalidation_event_associations ' )
121
+ $ partitionCache_invalidation_event_associations = "p_ {$ processingStartTime ->year }w {$ processingStartTime ->weekOfYear }" ;
122
+ $ associations = DB ::table (DB ::raw ("`cache_invalidation_event_associations` PARTITION ( {$ partitionCache_invalidation_event_associations }) " ))
110
123
->whereIn ('event_id ' , $ eventIds )
111
124
->get ()
112
125
->groupBy ('event_id ' )
@@ -313,7 +326,7 @@ protected function processBatch(array $batchIdentifiers, array $eventsToUpdate):
313
326
{
314
327
315
328
// Begin transaction for the batch
316
- DB ::beginTransaction ();
329
+ // DB::beginTransaction();
317
330
318
331
try {
319
332
// Separate keys and tags
@@ -368,10 +381,10 @@ protected function processBatch(array $batchIdentifiers, array $eventsToUpdate):
368
381
;
369
382
370
383
// Commit transaction
371
- DB ::commit ();
384
+ // DB::commit();
372
385
} catch (\Exception $ e ) {
373
386
// Rollback transaction on error
374
- DB ::rollBack ();
387
+ // DB::rollBack();
375
388
throw $ e ;
376
389
}
377
390
}
0 commit comments