Files
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

28 lines
688 B
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Actions\Servers;
use Illuminate\Support\Facades\Cache;
use Pterodactyl\Contracts\Servers\ReadsServerState;
use Pterodactyl\Data\ServerState;
use Pterodactyl\Facades\Daemon;
use Pterodactyl\Models\Server;
final readonly class ReadServerState implements ReadsServerState
{
private const int CACHE_SECONDS = 20;
public function read(Server $server): ServerState
{
$stats = Cache::remember(
"resources:$server->uuid",
now()->addSeconds(self::CACHE_SECONDS),
fn (): array => Daemon::server($server)->details(),
);
return ServerState::fromDaemon($stats);
}
}