mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 09:36:52 +01:00 
			
		
		
		
	Cache the statuses for a bit
This commit is contained in:
		
							parent
							
								
									bab4315bb7
								
							
						
					
					
						commit
						4b23703f99
					
				| @ -292,14 +292,12 @@ class Node extends Model | ||||
| 
 | ||||
|     public function serverStatuses(): array | ||||
|     { | ||||
|         try { | ||||
|             /** @var \Illuminate\Http\Client\Response $response */ | ||||
|             $response = Http::daemon($this)->connectTimeout(1)->timeout(1)->get('/api/servers'); | ||||
|             $statuses = $response->json(); | ||||
|         } catch (Exception) { | ||||
|             $statuses = []; | ||||
|         } | ||||
| 
 | ||||
|         return cache()->remember("nodes.$this->id.servers", now()->addSeconds(2), fn () => $statuses); | ||||
|         return cache()->remember("nodes.$this->id.servers", now()->addMinute(), function () { | ||||
|             try { | ||||
|                 return Http::daemon($this)->connectTimeout(1)->timeout(1)->get('/api/servers')->json(); | ||||
|             } catch (Exception) { | ||||
|                 return []; | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Lance Pioch
						Lance Pioch