@@ -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 | |
@@ -333,10 +333,10 @@ discard block |
||
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 |
||
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 | } |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | } |
422 | 422 | |
423 | 423 | // oppure di default uso Laravel |
424 | - $storeName = $this->getStoreFromConnectionName($connection_name); |
|
424 | + $storeName = $this->getStoreFromConnectionName($connection_name); |
|
425 | 425 | |
426 | 426 | if ($storeName === null) { |
427 | 427 | return; |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | return; |
459 | 459 | } |
460 | 460 | foreach ($groupByConnection as $connection_name => $arrTags) { |
461 | - $storeName = $this->getStoreFromConnectionName($connection_name); |
|
461 | + $storeName = $this->getStoreFromConnectionName($connection_name); |
|
462 | 462 | if ($storeName === null) { |
463 | 463 | return; |
464 | 464 | } |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | $shardId = (int) $this->option('shard'); |
475 | 475 | $priority = (int) $this->option('priority'); |
476 | 476 | $limit = $this->option('limit') ?? config('super_cache_invalidate.processing_limit'); |
477 | - $limit = (int)$limit; |
|
477 | + $limit = (int) $limit; |
|
478 | 478 | $tagBatchSize = $this->option('tag-batch-size') ?? config('super_cache_invalidate.tag_batch_size'); |
479 | - $tagBatchSize = (int)$tagBatchSize; |
|
479 | + $tagBatchSize = (int) $tagBatchSize; |
|
480 | 480 | $lockTimeout = (int) config('super_cache_invalidate.lock_timeout'); |
481 | 481 | $connection_name = $this->option('connection_name') ?? config('super_cache_invalidate.default_connection_name'); |
482 | 482 | /* |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | try { |
496 | 496 | $this->processEvents($shardId, $priority, $limit, $tagBatchSize, $connection_name); |
497 | 497 | } catch (\Throwable $e) { |
498 | - $this->error(now() . ' Si è verificato un errore in ' . __METHOD__ . ': ' . $e->getMessage()); |
|
498 | + $this->error(now().' Si è verificato un errore in '.__METHOD__.': '.$e->getMessage()); |
|
499 | 499 | } finally { |
500 | 500 | $this->helper->releaseShardLock($shardId, $priority, $lockValue, $connection_name); |
501 | 501 | } |
@@ -77,11 +77,11 @@ discard block |
||
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 |
||
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 |
||
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); |