Passed
Pull Request — main (#3)
by
unknown
03:02
created
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.