From c2008481800d7c175c94cf8f778f5e2fe6f13c80 Mon Sep 17 00:00:00 2001 From: qianhy Date: Wed, 26 Apr 2023 15:51:52 +0800 Subject: [PATCH] plan add last_runtime --- api/controllers/plan/Plan.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/controllers/plan/Plan.php b/api/controllers/plan/Plan.php index 5d9dbdf6..a5608e26 100644 --- a/api/controllers/plan/Plan.php +++ b/api/controllers/plan/Plan.php @@ -11,6 +11,7 @@ class Plan extends CI_Controller { private $plan; + private $key_last_runtime = 'lc_plan_last_runtime'; protected $log_dir; @@ -64,6 +65,14 @@ class Plan extends CI_Controller $this->plan = $plan; } + public function last_runtime(){ + $redis = &load_cache('redis'); + $value = $redis->get($this->key_last_runtime); + !$value && $value = 0; + $dts = $value ? date("Y-m-d H:i:s", $value) : ''; + echo json_encode(array('last_runtime'=>$value, 'datetime' => $dts), JSON_UNESCAPED_UNICODE); + } + public function index() { $plan = $this->plan; @@ -88,6 +97,9 @@ class Plan extends CI_Controller echo "Finished " . date("Y-m-d H:i:s") . "\n"; } + + $redis = &load_cache('redis'); + $redis->save($this->key_last_runtime, time()); } /*