|
@@ -93,11 +93,11 @@ discard block |
|
|
block discarded – undo |
|
93
|
93
|
} catch (\Throwable $e) { |
|
94
|
94
|
// DB::rollBack(); // Annulla la transazione in caso di errore |
|
95
|
95
|
$attempts++; |
|
96
|
|
- Log::error("SuperCacheInvalidate: impossibile eseguire insert, tentativo $attempts di $maxAttempts: " . $e->getMessage()); |
|
|
96
|
+ Log::error("SuperCacheInvalidate: impossibile eseguire insert, tentativo $attempts di $maxAttempts: ".$e->getMessage()); |
|
97
|
97
|
// Logica per gestire i tentativi falliti |
|
98
|
98
|
if ($attempts >= $maxAttempts) { |
|
99
|
99
|
// Salta il record dopo il numero massimo di tentativi |
|
100
|
|
- Log::error("SuperCacheInvalidate: impossibile eseguire insert dopo $maxAttempts tentativi: " . $e->getMessage()); |
|
|
100
|
+ Log::error("SuperCacheInvalidate: impossibile eseguire insert dopo $maxAttempts tentativi: ".$e->getMessage()); |
|
101
|
101
|
} |
|
102
|
102
|
} |
|
103
|
103
|
} |
|
@@ -111,9 +111,9 @@ discard block |
|
|
block discarded – undo |
|
111
|
111
|
* @param string $connection_name The Redis Connection name |
|
112
|
112
|
* @return string|false The lock value if acquired, false otherwise |
|
113
|
113
|
*/ |
|
114
|
|
- public function acquireShardLock(int $shardId, int $priority, int $lockTimeout, string $connection_name): bool|string |
|
|
114
|
+ public function acquireShardLock(int $shardId, int $priority, int $lockTimeout, string $connection_name): bool | string |
|
115
|
115
|
{ |
|
116
|
|
- $lockKey = 'shard_lock:' . $shardId . '_' . $priority; |
|
|
116
|
+ $lockKey = 'shard_lock:'.$shardId.'_'.$priority; |
|
117
|
117
|
// Il metodo has/exists occupa troppa memoria!!! |
|
118
|
118
|
$retrieveValue = Redis::connection($connection_name)->get($lockKey); |
|
119
|
119
|
if ($retrieveValue !== null) { |
|
@@ -139,7 +139,7 @@ discard block |
|
|
block discarded – undo |
|
139
|
139
|
*/ |
|
140
|
140
|
public function releaseShardLock(int $shardId, int $priority, string $lockValue, string $connection_name): void |
|
141
|
141
|
{ |
|
142
|
|
- $lockKey = 'shard_lock:' . $shardId . '_' . $priority; |
|
|
142
|
+ $lockKey = 'shard_lock:'.$shardId.'_'.$priority; |
|
143
|
143
|
$currentValue = Redis::connection($connection_name)->get($lockKey); |
|
144
|
144
|
if ($currentValue === $lockValue) { |
|
145
|
145
|
Redis::connection($connection_name)->del($lockKey); |