Only keep the last 120 stored stats (#1805)

This commit is contained in:
Boy132 2025-10-13 22:50:16 +02:00 committed by GitHub
parent d735e858a2
commit 2cd9fa2cde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -121,11 +121,11 @@ class ServerConsole extends Widget
foreach ($data as $key => $value) {
$cacheKey = "servers.{$this->server->id}.$key";
$data = cache()->get($cacheKey, []);
$cachedStats = cache()->get($cacheKey, []);
$data[$timestamp] = $value;
$cachedStats[$timestamp] = $value;
cache()->put($cacheKey, $data, now()->addMinute());
cache()->put($cacheKey, array_slice($cachedStats, -120), now()->addMinute());
}
}