From 42fa8304ddb811b0f725f245130f70c0f5e86a6c Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 04 Nov 2025 06:12:02 +0000
Subject: [PATCH] =Refactored LoginManager to be more extensible and configurable, as well as an AjaxRateLimiter

---
 inc/managers/UserTermsManager.php |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/inc/managers/UserTermsManager.php b/inc/managers/UserTermsManager.php
index efde9cd..5eb29f2 100644
--- a/inc/managers/UserTermsManager.php
+++ b/inc/managers/UserTermsManager.php
@@ -23,8 +23,6 @@
         global $wpdb;
 		$this->wpdb = $wpdb;
         $this->table_name = $this->wpdb->prefix . BASE . 'user_term_index';
-        // Get cache manager instance
-        $this->cache = new CacheManager($this->cacheGroup, $this->ttl);
 
         // Register hooks
         add_action('save_post', [$this, 'updatePostUserTerms'], 10, 3);
@@ -43,14 +41,11 @@
      */
     public function clearUserCache(int $user_id, string|null $taxonomy = null):void
     {
+		$cache = CacheManager::for($user_id.'_term_relationships');
         if ($taxonomy) {
-            // Clear specific taxonomy cache
-            $pattern = "user_{$user_id}_" . str_replace(BASE, '', $taxonomy);
-            $this->cache->clearPattern($pattern);
+            $cache->delete(jvbNoBase($taxonomy));
         } else {
-            // Clear all user term caches
-            $pattern = "user_{$user_id}_";
-            $this->cache->clearPattern($pattern);
+			$cache->invalidate();
         }
     }
 
@@ -592,7 +587,8 @@
     private function fetchUserTerms(int $user_id, string $taxonomy, array $args):array
     {
         $taxonomy = jvbCheckBase($taxonomy);
-        $key = $this->cache->generateKey(array_merge(
+		$cache = CacheManager::for($user_id.'_term_relationships');
+        $key = $cache->generateKey(array_merge(
             [
                 'user'      => $user_id,
                 'taxonomy'  => $taxonomy,
@@ -600,9 +596,9 @@
             $args
         ));
         if (!$args['skip_cache']) {
-            $cache = $this->cache->get($key);
-            if ($cache) {
-                return $cache;
+            $cached = $cache->get($key);
+            if ($cached) {
+                return $cached;
             }
         }
 
@@ -654,7 +650,7 @@
             $this->wpdb->prepare($query, $query_args),
             ARRAY_A
         );
-        $this->cache->set($key, $results);
+        $cache->set($key, $results);
 
         return $results;
     }

--
Gitblit v1.10.0