| @@ -100,8 +100,8 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | |
| @@ -338,10 +338,10 @@ discard block | ||
| 338 | 338 |          foreach ($batchIdentifiers as $item) { | 
| 339 | 339 |              switch ($item['type']) { | 
| 340 | 340 | case 'key': | 
| 341 | - $keys[] = $item['identifier'] . '§' . $item['connection_name']; | |
| 341 | + $keys[] = $item['identifier'].'§'.$item['connection_name']; | |
| 342 | 342 | break; | 
| 343 | 343 | case 'tag': | 
| 344 | - $tags[] = $item['identifier'] . '§' . $item['connection_name']; | |
| 344 | + $tags[] = $item['identifier'].'§'.$item['connection_name']; | |
| 345 | 345 | break; | 
| 346 | 346 | } | 
| 347 | 347 | |
| @@ -353,10 +353,10 @@ discard block | ||
| 353 | 353 |              foreach ($item['associated'] as $assoc) { | 
| 354 | 354 |                  switch ($assoc['type']) { | 
| 355 | 355 | case 'key': | 
| 356 | - $keys[] = $assoc['identifier'] . '§' . $assoc['connection_name']; | |
| 356 | + $keys[] = $assoc['identifier'].'§'.$assoc['connection_name']; | |
| 357 | 357 | break; | 
| 358 | 358 | case 'tag': | 
| 359 | - $tags[] = $assoc['identifier'] . '§' . $assoc['connection_name']; | |
| 359 | + $tags[] = $assoc['identifier'].'§'.$assoc['connection_name']; | |
| 360 | 360 | break; | 
| 361 | 361 | } | 
| 362 | 362 | } | 
| @@ -406,7 +406,7 @@ discard block | ||
| 406 | 406 | // Rollback transaction on error | 
| 407 | 407 | //DB::rollBack(); | 
| 408 | 408 | $attempts++; | 
| 409 | - $this->warn(now()->toDateTimeString() . ": Tentativo $attempts di $maxAttempts: " . $e->getMessage()); | |
| 409 | + $this->warn(now()->toDateTimeString().": Tentativo $attempts di $maxAttempts: ".$e->getMessage()); | |
| 410 | 410 | // Logica per gestire i tentativi falliti | 
| 411 | 411 |                  if ($attempts >= $maxAttempts) { | 
| 412 | 412 | // Salta il record dopo il numero massimo di tentativi | 
| @@ -438,7 +438,7 @@ discard block | ||
| 438 | 438 | } | 
| 439 | 439 | |
| 440 | 440 | // oppure di default uso Laravel | 
| 441 | - $storeName = $this->getStoreFromConnectionName($connection_name); | |
| 441 | + $storeName = $this->getStoreFromConnectionName($connection_name); | |
| 442 | 442 | |
| 443 | 443 |              if ($storeName === null) { | 
| 444 | 444 | return; | 
| @@ -475,7 +475,7 @@ discard block | ||
| 475 | 475 | return; | 
| 476 | 476 | } | 
| 477 | 477 |          foreach ($groupByConnection as $connection_name => $arrTags) { | 
| 478 | - $storeName = $this->getStoreFromConnectionName($connection_name); | |
| 478 | + $storeName = $this->getStoreFromConnectionName($connection_name); | |
| 479 | 479 |              if ($storeName === null) { | 
| 480 | 480 | return; | 
| 481 | 481 | } | 
| @@ -491,9 +491,9 @@ discard block | ||
| 491 | 491 |          $shardId = (int) $this->option('shard'); | 
| 492 | 492 |          $priority = (int) $this->option('priority'); | 
| 493 | 493 |          $limit = $this->option('limit') ?? config('super_cache_invalidate.processing_limit'); | 
| 494 | - $limit = (int)$limit; | |
| 494 | + $limit = (int) $limit; | |
| 495 | 495 |          $tagBatchSize = $this->option('tag-batch-size') ?? config('super_cache_invalidate.tag_batch_size'); | 
| 496 | - $tagBatchSize = (int)$tagBatchSize; | |
| 496 | + $tagBatchSize = (int) $tagBatchSize; | |
| 497 | 497 |          $lockTimeout = (int) config('super_cache_invalidate.lock_timeout'); | 
| 498 | 498 |          $connection_name = $this->option('connection_name') ?? config('super_cache_invalidate.default_connection_name'); | 
| 499 | 499 | /* | 
| @@ -512,7 +512,7 @@ discard block | ||
| 512 | 512 |          try { | 
| 513 | 513 | $this->processEvents($shardId, $priority, $limit, $tagBatchSize, $connection_name); | 
| 514 | 514 |          } catch (\Throwable $e) { | 
| 515 | - $this->error(now()->toDateTimeString() . ': Si è verificato un errore in ' . __METHOD__ . ': ' . $e->getMessage()); | |
| 515 | + $this->error(now()->toDateTimeString().': Si è verificato un errore in '.__METHOD__.': '.$e->getMessage()); | |
| 516 | 516 |          } finally { | 
| 517 | 517 | $this->helper->releaseShardLock($shardId, $priority, $lockValue, $connection_name); | 
| 518 | 518 | } | 
| @@ -79,11 +79,11 @@ discard block | ||
| 79 | 79 |              } catch (\Throwable $e) { | 
| 80 | 80 | //DB::rollBack(); // Annulla la transazione in caso di errore | 
| 81 | 81 | $attempts++; | 
| 82 | -                Log::error("SuperCacheInvalidate: impossibile eseguire insert, tentativo $attempts di $maxAttempts: " . $e->getMessage()); | |
| 82 | +                Log::error("SuperCacheInvalidate: impossibile eseguire insert, tentativo $attempts di $maxAttempts: ".$e->getMessage()); | |
| 83 | 83 | // Logica per gestire i tentativi falliti | 
| 84 | 84 |                  if ($attempts >= $maxAttempts) { | 
| 85 | 85 | // Salta il record dopo il numero massimo di tentativi | 
| 86 | -                    Log::error("SuperCacheInvalidate: impossibile eseguire insert dopo $maxAttempts tentativi: " . $e->getMessage()); | |
| 86 | +                    Log::error("SuperCacheInvalidate: impossibile eseguire insert dopo $maxAttempts tentativi: ".$e->getMessage()); | |
| 87 | 87 | } | 
| 88 | 88 | } | 
| 89 | 89 | } | 
| @@ -97,9 +97,9 @@ discard block | ||
| 97 | 97 | * @param string $connection_name The Redis Connection name | 
| 98 | 98 | * @return string|false The lock value if acquired, false otherwise | 
| 99 | 99 | */ | 
| 100 | - public function acquireShardLock(int $shardId, int $priority, int $lockTimeout, string $connection_name): bool|string | |
| 100 | + public function acquireShardLock(int $shardId, int $priority, int $lockTimeout, string $connection_name): bool | string | |
| 101 | 101 |      { | 
| 102 | - $lockKey = 'shard_lock:' . $shardId . '_' . $priority; | |
| 102 | + $lockKey = 'shard_lock:'.$shardId.'_'.$priority; | |
| 103 | 103 | // Il metodo has/exists occupa troppa memoria!!! | 
| 104 | 104 | $retrieveValue = Redis::connection($connection_name)->get($lockKey); | 
| 105 | 105 |          if ($retrieveValue !== null) { | 
| @@ -125,7 +125,7 @@ discard block | ||
| 125 | 125 | */ | 
| 126 | 126 | public function releaseShardLock(int $shardId, int $priority, string $lockValue, string $connection_name): void | 
| 127 | 127 |      { | 
| 128 | - $lockKey = 'shard_lock:' . $shardId . '_' . $priority; | |
| 128 | + $lockKey = 'shard_lock:'.$shardId.'_'.$priority; | |
| 129 | 129 | $currentValue = Redis::connection($connection_name)->get($lockKey); | 
| 130 | 130 |          if ($currentValue === $lockValue) { | 
| 131 | 131 | Redis::connection($connection_name)->del($lockKey); |