From 7edd708f85562943539ec927775c1b083f079b2d Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Mon, 27 Jun 2016 18:48:48 +0200 Subject: [PATCH 1/1] only cache the last_update value for 10 seconds, so that we can reasonably use this function to wait for updates but still don't flodd the commandline with requests --- include/classes/rrdstat.php-class | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/classes/rrdstat.php-class b/include/classes/rrdstat.php-class index aa7079d..ce334e0 100644 --- a/include/classes/rrdstat.php-class +++ b/include/classes/rrdstat.php-class @@ -476,11 +476,13 @@ class rrdstat { public function last_update() { // fetch time of last update in this RRD file - static $last_update; + static $last_update, $last_saved; + if (isset($last_update) && isset($last_saved) && ($last_saved <= (time() - 10))) { unset($last_update); } if (!isset($last_update) && in_array($this->status, array('ok','readonly'))) { $last_cmd = $this->rrdtool_bin.' last '.$this->rrd_file; $return = trim(`$last_cmd 2>&1`); $last_update = is_numeric($return)?$return:null; + $last_saved = time(); } return isset($last_update)?$last_update:null; } -- 2.35.3