Passed
Pull Request — main (#3)
by
unknown
03:04
created
src/Console/PruneCacheInvalidationDataCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
         }
48 48
 
49 49
         // Build DROP PARTITION statement
50
-        $partitionNames = implode(', ', array_map(function ($partition) {
50
+        $partitionNames = implode(', ', array_map(function($partition) {
51 51
             return $partition->PARTITION_NAME;
52 52
         }, $partitions));
53 53
 
Please login to merge, or discard this patch.
migrations/2024_11_20_200800_create_cache_invalidation_events_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
             return;
58 58
         }
59 59
 
60
-        Schema::create('cache_invalidation_events', function (Blueprint $table) {
60
+        Schema::create('cache_invalidation_events', function(Blueprint $table) {
61 61
             //$table->bigIncrements('id');
62 62
             $table->bigInteger('id')->unsigned(); // Definiamo l'ID come bigInteger senza autoincrement sennò la primarykey multipla non funziona
63 63
             $table->enum('type', ['key', 'tag'])->comment('Indicates whether the event is for a cache key or tag');
Please login to merge, or discard this patch.
2024_11_20_200802_create_cache_invalidation_event_associations_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
         if (Schema::hasTable('cache_invalidation_event_associations')) {
15 15
             return;
16 16
         }
17
-        Schema::create('cache_invalidation_event_associations', function (Blueprint $table) {
17
+        Schema::create('cache_invalidation_event_associations', function(Blueprint $table) {
18 18
             //$table->bigIncrements('id');
19 19
             $table->bigInteger('id')->unsigned(); // Definiamo l'ID come bigInteger senza autoincrement sennò la primarykey multipla non funziona
20 20
             $table->unsignedBigInteger('event_id')->comment('Reference to cache_invalidation_events.id');
Please login to merge, or discard this patch.
migrations/2024_11_20_200801_create_cache_invalidation_timestamps_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
         if (Schema::hasTable('cache_invalidation_timestamps')) {
15 15
             return;
16 16
         }
17
-        Schema::create('cache_invalidation_timestamps', function (Blueprint $table) {
17
+        Schema::create('cache_invalidation_timestamps', function(Blueprint $table) {
18 18
             $table->enum('identifier_type', ['key', 'tag'])->comment('Indicates whether the identifier is a cache key or tag');
19 19
             $table->string('identifier')->comment('The cache key or tag');
20 20
             $table->dateTime('last_invalidated')->comment('Timestamp of the last invalidation');
Please login to merge, or discard this patch.
src/Helpers/SuperCacheInvalidationHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
      * @param  string       $connection_name The Redis Connection name
69 69
      * @return string|false The lock value if acquired, false otherwise
70 70
      */
71
-    public function acquireShardLock(int $shardId, int $lockTimeout, string $connection_name): bool|string
71
+    public function acquireShardLock(int $shardId, int $lockTimeout, string $connection_name): bool | string
72 72
     {
73 73
         $lockKey = "shard_lock:$shardId";
74 74
         // Il metodo has/exists occupa troppa memoria!!!
Please login to merge, or discard this patch.
src/SuperCacheInvalidateServiceProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
     {
17 17
         // Merge package configuration
18 18
         $this->mergeConfigFrom(
19
-            __DIR__ . '/../config/super_cache_invalidate.php',
19
+            __DIR__.'/../config/super_cache_invalidate.php',
20 20
             'super_cache_invalidate'
21 21
         );
22 22
 
23 23
         // Register the helper as a singleton
24
-        $this->app->singleton(SuperCacheInvalidationHelper::class, function () {
24
+        $this->app->singleton(SuperCacheInvalidationHelper::class, function() {
25 25
             return new SuperCacheInvalidationHelper();
26 26
         });
27 27
 
28
-        $this->app->singleton('super_cache_invalidate', function () {
28
+        $this->app->singleton('super_cache_invalidate', function() {
29 29
             return new SuperCacheInvalidationHelper();
30 30
         });
31 31
     }
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
     {
38 38
         // Publish configuration
39 39
         $this->publishes([
40
-            __DIR__ . '/../config/super_cache_invalidate.php' => config_path('super_cache_invalidate.php'),
40
+            __DIR__.'/../config/super_cache_invalidate.php' => config_path('super_cache_invalidate.php'),
41 41
         ], 'config');
42 42
 
43 43
         // Publish migrations
44
-        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
44
+        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
45 45
         // Register commands
46 46
         if ($this->app->runningInConsole()) {
47 47
             $this->commands([
Please login to merge, or discard this patch.
src/Console/ProcessCacheInvalidationEventsCommand.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
         //retrive associated identifiers related to fetched event id
136 136
         // Per le chiavi/tag associati non filtro per connection_name, potrebbero esserci associazioni anche in altri database
137 137
         $associations = DB::table('cache_invalidation_event_associations')
138
-                          ->whereIn('event_id', $eventIds)
139
-                          ->get()
140
-                          ->groupBy('event_id')
138
+                            ->whereIn('event_id', $eventIds)
139
+                            ->get()
140
+                            ->groupBy('event_id')
141 141
         ;
142 142
 
143 143
         // Prepare list of all identifiers to fetch last invalidation times
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
         foreach ($identifiers as $key) {
322 322
             [$type, $identifier] = explode(':', $key, 2);
323 323
             DB::table('cache_invalidation_timestamps')
324
-              ->updateOrInsert(
325
-                  ['identifier_type' => $type, 'identifier' => $identifier],
326
-                  ['last_invalidated' => $now]
327
-              )
324
+                ->updateOrInsert(
325
+                    ['identifier_type' => $type, 'identifier' => $identifier],
326
+                    ['last_invalidated' => $now]
327
+                )
328 328
             ;
329 329
         }
330 330
     }
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 
392 392
             // Mark events as processed
393 393
             DB::table('cache_invalidation_events')
394
-              ->whereIn('id', $eventsToUpdate)
395
-              ->update(['processed' => 1])
394
+                ->whereIn('id', $eventsToUpdate)
395
+                ->update(['processed' => 1])
396 396
             ;
397 397
 
398 398
             // Commit transaction
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
         }
122 122
 
123 123
         // Group events by type and identifier
124
-        $eventsByIdentifier = $events->groupBy(function ($event) {
125
-            return $event->type . ':' . $event->identifier;
124
+        $eventsByIdentifier = $events->groupBy(function($event) {
125
+            return $event->type.':'.$event->identifier;
126 126
         });
127 127
 
128 128
         $batchIdentifiers = [];
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             foreach ($eventsGroup as $event) {
148 148
                 $eventAssociations = $associations->where('event_id', '=', $event->id);
149 149
                 foreach ($eventAssociations as $assoc) {
150
-                    $assocKey = $assoc->associated_type . ':' . $assoc->associated_identifier;
150
+                    $assocKey = $assoc->associated_type.':'.$assoc->associated_identifier;
151 151
                     $allIdentifiers[] = $assocKey;
152 152
                 }
153 153
             }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
             foreach ($eventsGroup as $event) {
165 165
                 $eventAssociations = $associations->where('event_id', '=', $event->id);
166 166
                 foreach ($eventAssociations as $assoc) {
167
-                    $assocKey = $assoc->associated_type . ':' . $assoc->associated_identifier;
167
+                    $assocKey = $assoc->associated_type.':'.$assoc->associated_identifier;
168 168
                     $associatedIdentifiers[$assocKey] = [
169 169
                         'type' => $assoc->associated_type,
170 170
                         'identifier' => $assoc->associated_identifier,
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     protected function getLastInvalidationTimes(array $identifiers): array
240 240
     {
241 241
         // Extract types and identifiers into tuples
242
-        $tuples = array_map(static function ($key) {
242
+        $tuples = array_map(static function($key) {
243 243
             return explode(':', $key, 2);
244 244
         }, $identifiers);
245 245
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         // Build associative array
253 253
         $lastInvalidationTimes = [];
254 254
         foreach ($records as $record) {
255
-            $key = $record->identifier_type . ':' . $record->identifier;
255
+            $key = $record->identifier_type.':'.$record->identifier;
256 256
             $lastInvalidationTimes[$key] = Carbon::parse($record->last_invalidated);
257 257
         }
258 258
 
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
             foreach ($batchIdentifiers as $item) {
352 352
                 switch ($item['type']) {
353 353
                     case 'key':
354
-                        $keys[] = $item['identifier'] . '§' . $item['connection_name'];
354
+                        $keys[] = $item['identifier'].'§'.$item['connection_name'];
355 355
                         break;
356 356
                     case 'tag':
357
-                        $tags[] = $item['identifier'] . '§' . $item['connection_name'];
357
+                        $tags[] = $item['identifier'].'§'.$item['connection_name'];
358 358
                         break;
359 359
                 }
360 360
 
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
                 foreach ($item['associated'] as $assoc) {
367 367
                     switch ($assoc['type']) {
368 368
                         case 'key':
369
-                            $keys[] = $assoc['identifier'] . '§' . $assoc['connection_name'];
369
+                            $keys[] = $assoc['identifier'].'§'.$assoc['connection_name'];
370 370
                             break;
371 371
                         case 'tag':
372
-                            $tags[] = $assoc['identifier'] . '§' . $assoc['connection_name'];
372
+                            $tags[] = $assoc['identifier'].'§'.$assoc['connection_name'];
373 373
                             break;
374 374
                     }
375 375
                 }
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
             }
426 426
 
427 427
             // oppure di default uso Laravel
428
-            $storeName =  $this->getStoreFromConnectionName($connection_name);
428
+            $storeName = $this->getStoreFromConnectionName($connection_name);
429 429
 
430 430
             if ($storeName === null) {
431 431
                 return;
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
             return;
462 462
         }
463 463
         foreach ($groupByConnection as $connection_name => $arrTags) {
464
-            $storeName =  $this->getStoreFromConnectionName($connection_name);
464
+            $storeName = $this->getStoreFromConnectionName($connection_name);
465 465
             if ($storeName === null) {
466 466
                 return;
467 467
             }
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
         $shardId = (int) $this->option('shard');
478 478
         $priority = (int) $this->option('priority');
479 479
         $limit = $this->option('limit') ?? config('super_cache_invalidate.processing_limit');
480
-        $limit = (int)$limit;
480
+        $limit = (int) $limit;
481 481
         $tagBatchSize = $this->option('tag-batch-size') ?? config('super_cache_invalidate.tag_batch_size');
482
-        $tagBatchSize = (int)$tagBatchSize;
482
+        $tagBatchSize = (int) $tagBatchSize;
483 483
         $lockTimeout = (int) config('super_cache_invalidate.lock_timeout');
484 484
         $connection_name = $this->option('connection_name') ?? config('super_cache_invalidate.default_connection_name');
485 485
         /*
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
         try {
499 499
             $this->processEvents($shardId, $priority, $limit, $tagBatchSize, $connection_name);
500 500
         } catch (\Exception $e) {
501
-            $this->error('Si è verificato un errore in ' . __METHOD__ . ': ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
501
+            $this->error('Si è verificato un errore in '.__METHOD__.': '.$e->getMessage().PHP_EOL.$e->getTraceAsString());
502 502
         } finally {
503 503
             $this->helper->releaseShardLock($shardId, $lockValue, $connection_name);
504 504
         }
Please login to merge, or discard this patch.