diff --git a/src/engine/Router.php b/src/engine/Router.php index ac05f3a..d14af21 100644 --- a/src/engine/Router.php +++ b/src/engine/Router.php @@ -4,9 +4,6 @@ namespace engine; class Router { - const int ROUTER_VERSION = 10; - const string ROUTER_MC_KEY = '4in1/routes'; - protected array $routes = [ 'children' => [], 're_children' => [] @@ -20,16 +17,17 @@ class Router } private function __construct() { - global $globalContext; + global $config, $globalContext; + $mc = getMC(); - + $mc_key = $globalContext->project.'/routes'; $from_cache = !isDev(); $write_cache = !isDev(); if ($from_cache) { - $cache = $mc->get(self::ROUTER_MC_KEY); + $cache = $mc->get($mc_key); - if ($cache === false || !isset($cache['version']) || $cache['version'] < self::ROUTER_VERSION) { + if ($cache === false || !isset($cache['commit_hash']) || $cache['commit_hash'] != $config['commit_hash']) { $from_cache = false; } else { $this->routes = $cache['routes']; @@ -45,7 +43,7 @@ class Router } if ($write_cache) - $mc->set(self::ROUTER_MC_KEY, ['version' => self::ROUTER_VERSION, 'routes' => $this->routes]); + $mc->set($mc_key, ['commit_hash' => $config['commit_hash'], 'routes' => $this->routes]); } }