From 0bcb773332839661ba66bfc73e673a34bac565db Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Thu, 4 Jun 2026 16:46:50 -0400 Subject: [PATCH] Cache: warm at array start, extend stale tolerance to 5 min, fix last uptime copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ARRAY_START_SCRIPTS: add api_cache_writer.sh so monitor/arrs cache is populated immediately on array start (/tmp is tmpfs — cleared on reboot, so first-boot load was hitting live API for up to 60 seconds until the cron fired) - api/monitor.php + arrs.php: raise cache TTL from 90s to 300s — stale-but-instant beats a 6-second live API wait if the writer is momentarily behind - include/unraid_api.php: replace last inline uptime formatter with vv_format_uptime() --- Plugin/unraid/api/arrs.php | 2 +- Plugin/unraid/api/monitor.php | 2 +- Plugin/unraid/include/unraid_api.php | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Plugin/unraid/api/arrs.php b/Plugin/unraid/api/arrs.php index 4379452..32cc23c 100644 --- a/Plugin/unraid/api/arrs.php +++ b/Plugin/unraid/api/arrs.php @@ -34,7 +34,7 @@ if ($_action === 'refresh_remote') { unset($_action); // ── Normal data load ────────────────────────────────────────────────────────── -$_vv_cached = vv_cache_read('arrs', 90); +$_vv_cached = vv_cache_read('arrs', 300); if ($_vv_cached !== null) { echo json_encode($_vv_cached); exit; } unset($_vv_cached); diff --git a/Plugin/unraid/api/monitor.php b/Plugin/unraid/api/monitor.php index 8943f46..2c113e6 100644 --- a/Plugin/unraid/api/monitor.php +++ b/Plugin/unraid/api/monitor.php @@ -2,7 +2,7 @@ header('Content-Type: application/json'); require_once dirname(__DIR__) . '/include/config.php'; -$_vv_cached = vv_cache_read('monitor', 90); +$_vv_cached = vv_cache_read('monitor', 300); if ($_vv_cached !== null) { echo json_encode($_vv_cached); exit; } unset($_vv_cached); diff --git a/Plugin/unraid/include/unraid_api.php b/Plugin/unraid/include/unraid_api.php index cef0a81..aa15aec 100644 --- a/Plugin/unraid/include/unraid_api.php +++ b/Plugin/unraid/include/unraid_api.php @@ -216,9 +216,8 @@ function vv_local_host_stats(): array { $uptimeRaw = $os['uptime'] ?? ''; if (is_numeric($uptimeRaw)) { - $s = (int)$uptimeRaw; - $d = intdiv($s, 86400); $h = intdiv($s % 86400, 3600); $m = intdiv($s % 3600, 60); - $uptime = ($d ? "{$d}d " : '') . ($h ? "{$h}h " : '') . "{$m}m"; + $s = (int)$uptimeRaw; + $uptime = vv_format_uptime($s); } else { $s = 0; $uptime = $uptimeRaw ?: '—'; }