mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-22 03:54:46 +02: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
|
public function serverStatuses(): array
|
||||||
{
|
{
|
||||||
try {
|
return cache()->remember("nodes.$this->id.servers", now()->addMinute(), function () {
|
||||||
/** @var \Illuminate\Http\Client\Response $response */
|
try {
|
||||||
$response = Http::daemon($this)->connectTimeout(1)->timeout(1)->get('/api/servers');
|
return Http::daemon($this)->connectTimeout(1)->timeout(1)->get('/api/servers')->json();
|
||||||
$statuses = $response->json();
|
} catch (Exception) {
|
||||||
} catch (Exception) {
|
return [];
|
||||||
$statuses = [];
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
return cache()->remember("nodes.$this->id.servers", now()->addSeconds(2), fn () => $statuses);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user