From e6672fe38ce5d99f3b3f026154f777aded7361de Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 29 Jan 2026 17:36:53 +0000
Subject: [PATCH] =Starting refactor of Meta and Routes to fluent-style

---
 inc/blocks/MenuBlock.php |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/inc/blocks/MenuBlock.php b/inc/blocks/MenuBlock.php
index b79d9ff..88fd26a 100644
--- a/inc/blocks/MenuBlock.php
+++ b/inc/blocks/MenuBlock.php
@@ -1,7 +1,7 @@
 <?php
 namespace JVBase\blocks;
 
-use JVBase\managers\CacheManager;
+use JVBase\managers\Cache;
 use JVBase\forms\TaxonomySelector;
 use JVBase\meta\MetaManager;
 use WP_Block;
@@ -13,7 +13,7 @@
 
 class MenuBlock
 {
-    protected CacheManager $cache;
+    protected Cache $cache;
     protected string $config;
     protected string $type;
     protected string $path = JVB_DIR . '/build/menu';
@@ -27,7 +27,7 @@
 
     public function __construct()
     {
-        $this->cache = new CacheManager('menu', WEEK_IN_SECONDS);
+        $this->cache = Cache::for('menu', WEEK_IN_SECONDS)->connectTo('post', 'menu_item');
         add_action('init', [ $this, 'registerBlock' ]);
     }
 
@@ -57,17 +57,14 @@
 			return '';
 		}
 		$key = $this->cache->generateKey($this->params);
-        $cache = $this->cache->get($key);
-        $cache = false;
-        if ($cache) {
-            return $cache;
-        }
-
-        ob_start();
-        $this->renderBlock();
-        $content = ob_get_clean();
-        $this->cache->set($key, $content);
-        return $content;
+		return $this->cache->remember(
+			$key,
+			function() {
+				ob_start();
+				$this->renderBlock();
+				return ob_get_clean();
+			}
+		);
     }
 
     protected function renderBlock():void

--
Gitblit v1.10.0