Passed
Pull Request — main (#3)
by
unknown
03:02
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/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/Helpers/SuperCacheInvalidationHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
             } catch (\Throwable $e) {
78 78
                 DB::rollBack(); // Annulla la transazione in caso di errore
79 79
                 $attempts++;
80
-                Log::error("SuperCacheInvalidate: impossibile eseguire insert, tentativo $attempts di $maxAttempts: " . $e->getMessage());
80
+                Log::error("SuperCacheInvalidate: impossibile eseguire insert, tentativo $attempts di $maxAttempts: ".$e->getMessage());
81 81
                 // Logica per gestire i tentativi falliti
82 82
                 if ($attempts >= $maxAttempts) {
83 83
                     // Salta il record dopo il numero massimo di tentativi
84
-                    Log::error("SuperCacheInvalidate: impossibile eseguire insert dopo $maxAttempts tentativi: " . $e->getMessage());
84
+                    Log::error("SuperCacheInvalidate: impossibile eseguire insert dopo $maxAttempts tentativi: ".$e->getMessage());
85 85
                 }
86 86
             }
87 87
         }
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
      * @param  string       $connection_name The Redis Connection name
96 96
      * @return string|false The lock value if acquired, false otherwise
97 97
      */
98
-    public function acquireShardLock(int $shardId, int $priority, int $lockTimeout, string $connection_name): bool|string
98
+    public function acquireShardLock(int $shardId, int $priority, int $lockTimeout, string $connection_name): bool | string
99 99
     {
100
-        $lockKey = 'shard_lock:' . $shardId . '_' . $priority;
100
+        $lockKey = 'shard_lock:'.$shardId.'_'.$priority;
101 101
         // Il metodo has/exists occupa troppa memoria!!!
102 102
         $retrieveValue = Redis::connection($connection_name)->get($lockKey);
103 103
         if ($retrieveValue !== null) {
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function releaseShardLock(int $shardId, int $priority, string $lockValue, string $connection_name): void
125 125
     {
126
-        $lockKey = 'shard_lock:' . $shardId . '_' . $priority;
126
+        $lockKey = 'shard_lock:'.$shardId.'_'.$priority;
127 127
         $currentValue = Redis::connection($connection_name)->get($lockKey);
128 128
         if ($currentValue === $lockValue) {
129 129
             Redis::connection($connection_name)->del($lockKey);
Please login to merge, or discard this patch.
src/Console/ProcessCacheInvalidationEventsCommand.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
         }
101 101
 
102 102
         // Group events by type and identifier
103
-        $eventsByIdentifier = $events->groupBy(function ($event) {
104
-            return $event->type . ':' . $event->identifier;
103
+        $eventsByIdentifier = $events->groupBy(function($event) {
104
+            return $event->type.':'.$event->identifier;
105 105
         });
106 106
 
107 107
         $batchIdentifiers = [];
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             foreach ($eventsGroup as $event) {
131 131
                 $eventAssociations = $associations->where('event_id', '=', $event->id);
132 132
                 foreach ($eventAssociations as $assoc) {
133
-                    $assocKey = $assoc->associated_type . ':' . $assoc->associated_identifier;
133
+                    $assocKey = $assoc->associated_type.':'.$assoc->associated_identifier;
134 134
                     $allIdentifiers[] = $assocKey;
135 135
                 }
136 136
             }
@@ -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
                     $associatedIdentifiers[$assocKey] = [
152 152
                         'type' => $assoc->associated_type,
153 153
                         'identifier' => $assoc->associated_identifier,
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     protected function getLastInvalidationTimes(array $identifiers): array
223 223
     {
224 224
         // Extract types and identifiers into tuples
225
-        $tuples = array_map(static function ($key) {
225
+        $tuples = array_map(static function($key) {
226 226
             return explode(':', $key, 2);
227 227
         }, $identifiers);
228 228
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         // Build associative array
236 236
         $lastInvalidationTimes = [];
237 237
         foreach ($records as $record) {
238
-            $key = $record->identifier_type . ':' . $record->identifier;
238
+            $key = $record->identifier_type.':'.$record->identifier;
239 239
             $lastInvalidationTimes[$key] = Carbon::parse($record->last_invalidated);
240 240
         }
241 241
 
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
         foreach ($batchIdentifiers as $item) {
334 334
             switch ($item['type']) {
335 335
                 case 'key':
336
-                    $keys[] = $item['identifier'] . '§' . $item['connection_name'];
336
+                    $keys[] = $item['identifier'].'§'.$item['connection_name'];
337 337
                     break;
338 338
                 case 'tag':
339
-                    $tags[] = $item['identifier'] . '§' . $item['connection_name'];
339
+                    $tags[] = $item['identifier'].'§'.$item['connection_name'];
340 340
                     break;
341 341
             }
342 342
 
@@ -348,10 +348,10 @@  discard block
 block discarded – undo
348 348
             foreach ($item['associated'] as $assoc) {
349 349
                 switch ($assoc['type']) {
350 350
                     case 'key':
351
-                        $keys[] = $assoc['identifier'] . '§' . $assoc['connection_name'];
351
+                        $keys[] = $assoc['identifier'].'§'.$assoc['connection_name'];
352 352
                         break;
353 353
                     case 'tag':
354
-                        $tags[] = $assoc['identifier'] . '§' . $assoc['connection_name'];
354
+                        $tags[] = $assoc['identifier'].'§'.$assoc['connection_name'];
355 355
                         break;
356 356
                 }
357 357
             }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
                 // Rollback transaction on error
391 391
                 DB::rollBack();
392 392
                 $attempts++;
393
-                $this->warn(now()->toDateTimeString() . ": Tentativo $attempts di $maxAttempts: " . $e->getMessage());
393
+                $this->warn(now()->toDateTimeString().": Tentativo $attempts di $maxAttempts: ".$e->getMessage());
394 394
                 // Logica per gestire i tentativi falliti
395 395
                 if ($attempts >= $maxAttempts) {
396 396
                     // Salta il record dopo il numero massimo di tentativi
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
             }
423 423
 
424 424
             // oppure di default uso Laravel
425
-            $storeName =  $this->getStoreFromConnectionName($connection_name);
425
+            $storeName = $this->getStoreFromConnectionName($connection_name);
426 426
 
427 427
             if ($storeName === null) {
428 428
                 return;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
             return;
460 460
         }
461 461
         foreach ($groupByConnection as $connection_name => $arrTags) {
462
-            $storeName =  $this->getStoreFromConnectionName($connection_name);
462
+            $storeName = $this->getStoreFromConnectionName($connection_name);
463 463
             if ($storeName === null) {
464 464
                 return;
465 465
             }
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
         $shardId = (int) $this->option('shard');
476 476
         $priority = (int) $this->option('priority');
477 477
         $limit = $this->option('limit') ?? config('super_cache_invalidate.processing_limit');
478
-        $limit = (int)$limit;
478
+        $limit = (int) $limit;
479 479
         $tagBatchSize = $this->option('tag-batch-size') ?? config('super_cache_invalidate.tag_batch_size');
480
-        $tagBatchSize = (int)$tagBatchSize;
480
+        $tagBatchSize = (int) $tagBatchSize;
481 481
         $lockTimeout = (int) config('super_cache_invalidate.lock_timeout');
482 482
         $connection_name = $this->option('connection_name') ?? config('super_cache_invalidate.default_connection_name');
483 483
         /*
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
         try {
497 497
             $this->processEvents($shardId, $priority, $limit, $tagBatchSize, $connection_name);
498 498
         } catch (\Throwable $e) {
499
-            $this->error(now()->toDateTimeString() . ': Si è verificato un errore in ' . __METHOD__ . ': ' . $e->getMessage());
499
+            $this->error(now()->toDateTimeString().': Si è verificato un errore in '.__METHOD__.': '.$e->getMessage());
500 500
         } finally {
501 501
             $this->helper->releaseShardLock($shardId, $priority, $lockValue, $connection_name);
502 502
         }
Please login to merge, or discard this patch.