| | |
| | | |
| | | ]; |
| | | |
| | | protected ?CacheManager $cache = null; |
| | | protected ?Cache $cache = null; |
| | | protected int $ttl = 300; |
| | | // Cache keys for different data types |
| | | private const CACHE_QUEUE_STATUS = 'status'; |
| | |
| | | { |
| | | global $wpdb; |
| | | $this->wpdb = $wpdb; |
| | | $this->cache = CacheManager::for('queue', DAY_IN_SECONDS); |
| | | $this->cache = Cache::for('queue', DAY_IN_SECONDS)->connect('user'); |
| | | add_action('jvb_process_queue', [ $this, 'checkQueue' ]); |
| | | add_action('jvb_queue_maintenance', [$this, 'hourlyMaintenance']); |
| | | add_action('jvbEmailDailyMetricsReport', [$this, 'emailDailyMetricsReport']); |
| | |
| | | $this->processOperation($operation); |
| | | |
| | | // Invalidate operation cache after processing |
| | | $this->cache->delete(self::CACHE_OPERATION_PREFIX . $operation->id); |
| | | $this->cache->delete(self::CACHE_USER_QUEUE_PREFIX . $operation->user_id); |
| | | $this->cache->forget(self::CACHE_OPERATION_PREFIX . $operation->id); |
| | | $this->cache->forget(self::CACHE_USER_QUEUE_PREFIX . $operation->user_id); |
| | | } |
| | | |
| | | // Batch invalidate caches at the end |
| | |
| | | */ |
| | | public function isUserQueueModified(int $user_id, int $since_timestamp): bool |
| | | { |
| | | return $this->cache::getTimestamp("user_{$user_id}") > $since_timestamp; |
| | | return $this->cache::lastModified("user_{$user_id}") > $since_timestamp; |
| | | } |
| | | protected function invalidateUserQueue(int $user_id): void |
| | | { |
| | |
| | | // 1. Updates HTTP timestamp for user_{$user_id} |
| | | // 2. Flushes user-specific caches |
| | | // 3. Triggers connected cache invalidation |
| | | CacheManager::invalidateAll("user_{$user_id}"); |
| | | Cache::for($user_id)->flush(); |
| | | } |
| | | |
| | | /** |
| | |
| | | $keys = $cacheKeys[$scope] ?? $cacheKeys['all']; |
| | | |
| | | foreach ($keys as $key) { |
| | | $this->cache->delete($key); |
| | | $this->cache->forget($key); |
| | | } |
| | | |
| | | $this->cache->touch(); |
| | |
| | | protected function updateUserQueueTimestamp(int $user_id) |
| | | { |
| | | |
| | | CacheManager::updateTimestamp("user_{$user_id}"); |
| | | Cache::touch("user_{$user_id}"); |
| | | } |
| | | |
| | | /** |