Jake Vanderwerf
2025-11-23 d7dbe7fee362d587dfc334135d9581b6216a4295
inc/managers/OperationQueue.php
@@ -3,6 +3,7 @@
use JVBase\managers\CacheManager;
use Exception;
use JVBase\utility\Features;
use WP_Error;
use WP_REST_Response;
use WP_REST_Request;
@@ -79,7 +80,7 @@
    {
      global $wpdb;
      $this->wpdb = $wpdb;
      $this->cache = new CacheManager('queue');
      $this->cache = CacheManager::for('queue', DAY_IN_SECONDS);
        add_action('jvb_process_queue', [ $this, 'checkQueue' ]);
      add_action('jvb_queue_maintenance', [$this, 'hourlyMaintenance']);
        add_action('jvbEmailDailyMetricsReport', [$this, 'emailDailyMetricsReport']);
@@ -579,7 +580,7 @@
         $this->updateLastModified($user_id);
         $this->invalidateQueueCache();
         $this->cache->invalidate(self::CACHE_USER_QUEUE_PREFIX . $user_id);
         $this->cache->delete(self::CACHE_USER_QUEUE_PREFIX . $user_id);
         $this->runQueueOnShutdown();
         return [
@@ -598,7 +599,7 @@
   }
   protected function updateLastModified(int $user_id) {
      JVB()->routes('queue')->updateUserQueueTimestamp($user_id);
      CacheManager::updateTimestamp("user_{$user_id}");
   }
   protected function deepMerge(array $existing, array $new): array
@@ -814,8 +815,8 @@
            $this->processOperation($operation);
            // Invalidate operation cache after processing
            $this->cache->invalidate(self::CACHE_OPERATION_PREFIX . $operation->id);
            $this->cache->invalidate(self::CACHE_USER_QUEUE_PREFIX . $operation->user_id);
            $this->cache->delete(self::CACHE_OPERATION_PREFIX . $operation->id);
            $this->cache->delete(self::CACHE_USER_QUEUE_PREFIX . $operation->user_id);
         }
         // Batch invalidate caches at the end
@@ -1025,13 +1026,12 @@
      $keys = $cacheKeys[$scope] ?? $cacheKeys['all'];
      foreach ($keys as $key) {
         $this->cache->invalidate($key);
         $this->cache->delete($key);
      }
      if ($scope === 'all') {
         // Clear entire group for complete refresh
         $this->cache->invalidateGroup($this->cacheGroup);
         jvbUpdateCacheTimestamp('queue');
         $this->cache->invalidate();
         delete_transient('jvb_queue_status_counts');
      }
   }
@@ -1406,7 +1406,7 @@
            }
         }
         // Clear operation cache after any update
         $this->cache->invalidate(self::CACHE_OPERATION_PREFIX . $operation->id);
         $this->cache->delete(self::CACHE_OPERATION_PREFIX . $operation->id);
         $this->updateLastModified($operation->user_id);
         return $filterResult;
@@ -1557,8 +1557,8 @@
    protected function updateUserQueueTimestamp(int $user_id)
    {
        $key = "{$user_id}_queue_timestamp";
      $this->cache->set($key, time());
      CacheManager::updateTimestamp("user_{$user_id}");
    }
   /**