@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if (!$this->log_attivo && $level === 'info') { |
73 | 73 | return; |
74 | 74 | } |
75 | - $this->$level(now()->toDateTimeString() . ' Shard[' . $this->shardId . '] Priority[' . $this->priority . '] Connection[' . $this->connection_name . '] : ' . PHP_EOL . $message); |
|
75 | + $this->$level(now()->toDateTimeString().' Shard['.$this->shardId.'] Priority['.$this->priority.'] Connection['.$this->connection_name.'] : '.PHP_EOL.$message); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | protected function processEvents(): void |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $processingStartTime = now(); |
81 | 81 | // Recupero gli eventi da invalidare |
82 | 82 | $events = $this->getEventsToInvalidate($processingStartTime); |
83 | - $this->logIf('Trovati ' . count($events) . ' Eventi da invalidare'); |
|
83 | + $this->logIf('Trovati '.count($events).' Eventi da invalidare'); |
|
84 | 84 | if (count($events) === 0) { |
85 | 85 | return; |
86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $unique_events = []; |
90 | 90 | |
91 | 91 | foreach ($events as $event) { |
92 | - $key = $event->type . ':' . $event->identifier; // Chiave univoca per type + identifier |
|
92 | + $key = $event->type.':'.$event->identifier; // Chiave univoca per type + identifier |
|
93 | 93 | $event->event_time = \Illuminate\Support\Carbon::parse($event->event_time); |
94 | 94 | // Quando la chiave non esiste o il nuovo valore ha un event_time più vecchio, lo sostituisco così a parità di tag ho sempre quello più vecchio e mi baso su quello per verificare la finestra |
95 | 95 | if (!isset($unique_events[$key]) || $event->event_time <= $unique_events[$key]->event_time) { |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | |
100 | 100 | $unique_events = array_values($unique_events); |
101 | 101 | |
102 | - $this->logIf('Eventi unici ' . count($unique_events)); |
|
102 | + $this->logIf('Eventi unici '.count($unique_events)); |
|
103 | 103 | // Quando il numero di eventi unici è inferiore al batchSize e quello più vecchio aspetta da almeno due minuti, mando l'invalidazione. |
104 | 104 | // Questo serve per i siti piccoli che hanno pochi eventi, altrimenti si rischia di attendere troppo per invalidare i tags |
105 | 105 | // In questo caso invalido i tag/key "unici" e setto a processed = 1 tutti quelli recuperati |
106 | 106 | if (count($unique_events) < $this->tagBatchSize && $processingStartTime->diffInSeconds($unique_events[0]->event_time) >= 120) { |
107 | - $this->logIf('Il numero di eventi unici è inferiore al batchSize ( ' . $this->tagBatchSize . ' ) e sono passati più di due minuti, procedo'); |
|
107 | + $this->logIf('Il numero di eventi unici è inferiore al batchSize ( '.$this->tagBatchSize.' ) e sono passati più di due minuti, procedo'); |
|
108 | 108 | $this->processBatch($events, $unique_events); |
109 | 109 | |
110 | 110 | return; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | // altrimenti aggiungo l'evento a quelli da processare |
125 | 125 | $eventsToUpdate[] = $event; |
126 | 126 | // e recupero tutti gli ID che hanno quel tag/key |
127 | - $eventsAll[] = array_filter($events, function ($event) use ($typeFilter, $identifierFilter) { |
|
127 | + $eventsAll[] = array_filter($events, function($event) use ($typeFilter, $identifierFilter) { |
|
128 | 128 | return $event->type === $typeFilter && $event->identifier === $identifierFilter; |
129 | 129 | }); |
130 | 130 | } |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | foreach ($eventsToInvalidate as $item) { |
144 | 144 | switch ($item->type) { |
145 | 145 | case 'key': |
146 | - $keys[] = $item->identifier . '§' . $item->connection_name; |
|
146 | + $keys[] = $item->identifier.'§'.$item->connection_name; |
|
147 | 147 | break; |
148 | 148 | case 'tag': |
149 | - $tags[] = $item->identifier . '§' . $item->connection_name; |
|
149 | + $tags[] = $item->identifier.'§'.$item->connection_name; |
|
150 | 150 | break; |
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - $this->logIf('Invalido ' . count($keys) . ' chiavi e ' . count($tags) . ' tags' . ' per un totale di ' . count($allEvents) . ' events_ID'); |
|
154 | + $this->logIf('Invalido '.count($keys).' chiavi e '.count($tags).' tags'.' per un totale di '.count($allEvents).' events_ID'); |
|
155 | 155 | |
156 | 156 | if (!empty($keys)) { |
157 | 157 | $this->invalidateKeys($keys); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | continue; |
197 | 197 | } |
198 | 198 | // oppure di default uso Laravel |
199 | - $storeName = $this->getStoreFromConnectionName($connection_name); |
|
199 | + $storeName = $this->getStoreFromConnectionName($connection_name); |
|
200 | 200 | |
201 | 201 | if ($storeName === null) { |
202 | 202 | continue; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | return; |
234 | 234 | } |
235 | 235 | foreach ($groupByConnection as $connection_name => $arrTags) { |
236 | - $storeName = $this->getStoreFromConnectionName($connection_name); |
|
236 | + $storeName = $this->getStoreFromConnectionName($connection_name); |
|
237 | 237 | if ($storeName === null) { |
238 | 238 | continue; |
239 | 239 | } |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | $tagBatchSize = $this->option('tag-batch-size') ?? config('super_cache_invalidate.tag_batch_size'); |
255 | 255 | $this->tagBatchSize = (int) $tagBatchSize; |
256 | 256 | $this->connection_name = $this->option('connection_name') ?? config('super_cache_invalidate.default_connection_name'); |
257 | - $this->log_attivo = $this->option('log_attivo') && (int)$this->option('log_attivo') === 1; |
|
257 | + $this->log_attivo = $this->option('log_attivo') && (int) $this->option('log_attivo') === 1; |
|
258 | 258 | $this->invalidation_window = (int) config('super_cache_invalidate.invalidation_window'); |
259 | 259 | $lockTimeout = (int) config('super_cache_invalidate.lock_timeout'); |
260 | 260 | |
261 | 261 | // Acquisisco il lock in modo da essere sicura che le esecuzioni non si accavallino |
262 | 262 | // $lockValue = $this->helper->acquireShardLock($this->shardId, $this->priority, $lockTimeout, $this->connection_name); |
263 | - $this->logIf('Starting Elaborazione ...' . $this->invalidation_window); |
|
263 | + $this->logIf('Starting Elaborazione ...'.$this->invalidation_window); |
|
264 | 264 | // if (!$lockValue) { |
265 | 265 | // return; |
266 | 266 | //} |
@@ -279,6 +279,6 @@ discard block |
||
279 | 279 | // $this->helper->releaseShardLock($this->shardId, $this->priority, $lockValue, $this->connection_name); |
280 | 280 | } |
281 | 281 | $executionTime = (microtime(true) - $startTime) * 1000; |
282 | - $this->logIf('Fine Elaborazione - Tempo di esecuzione: ' . $executionTime . ' millisec.'); |
|
282 | + $this->logIf('Fine Elaborazione - Tempo di esecuzione: '.$executionTime.' millisec.'); |
|
283 | 283 | } |
284 | 284 | } |