diff --git a/system/functions.php b/system/functions.php index e7f7db9d0..76b092337 100644 --- a/system/functions.php +++ b/system/functions.php @@ -589,24 +589,12 @@ function template_form() { global $template_name; - $cache = Cache::getInstance(); - if($cache->enabled()) - { - $tmp = ''; - if($cache->fetch('templates', $tmp)) { - $templates = unserialize($tmp); - } - else - { - $templates = get_templates(); - $cache->set('templates', serialize($templates), 30); - } - } - else - $templates = get_templates(); + $templates = Cache::remember('templates', 5 * 60, function() { + return get_templates(); + }); $options = ''; - foreach($templates as $key => $value) + foreach($templates as $value) $options .= ''; global $twig; diff --git a/system/template.php b/system/template.php index 09fea29ea..8a2258ff9 100644 --- a/system/template.php +++ b/system/template.php @@ -138,29 +138,19 @@ $twig_loader->prependPath(BASE . $template_path); } -function get_template_menus() { +function get_template_menus(): array +{ global $template_name; - $cache = Cache::getInstance(); - if ($cache->enabled()) { - $tmp = ''; - if ($cache->fetch('template_menus', $tmp)) { - $result = unserialize($tmp); - } - } - - if (!isset($result)) { - + $result = Cache::remember('template_menus', 10 * 60, function () use ($template_name) { $result = Menu::select(['name', 'link', 'blank', 'color', 'category']) ->where('template', $template_name) ->orderBy('category') ->orderBy('ordering') ->get(); - if ($cache->enabled()) { - $cache->set('template_menus', serialize($result->toArray()), 600); - } - } + return $result->toArray(); + }); $menus = array(); foreach($result as $menu) {