| | |
| | | exit; |
| | | } |
| | | |
| | | use JVBase\managers\CacheManager; |
| | | use JVBase\managers\Cache; |
| | | |
| | | class Storage |
| | | { |
| | | private \wpdb $wpdb; |
| | | private string $table; |
| | | private CacheManager $cache; |
| | | private Cache $cache; |
| | | |
| | | private const CACHE_USER_PREFIX = 'user_queue_'; |
| | | private const CACHE_QUEUE_INFO = 'queue_info'; |
| | | |
| | | public function __construct() |
| | |
| | | global $wpdb; |
| | | $this->wpdb = $wpdb; |
| | | $this->table = $wpdb->prefix . BASE . '_operation_queue'; |
| | | $this->cache = CacheManager::for('queue', DAY_IN_SECONDS); |
| | | $this->cache = Cache::for('queue', DAY_IN_SECONDS); |
| | | } |
| | | |
| | | public function hasProcessingOperations(): bool |
| | |
| | | |
| | | public function invalidateQueueCache(): void |
| | | { |
| | | $this->cache->delete(self::CACHE_QUEUE_INFO); |
| | | $this->cache->touch(); |
| | | $this->cache->forget(self::CACHE_QUEUE_INFO); |
| | | } |
| | | |
| | | private function invalidateUser(int $userId): void |
| | | { |
| | | CacheManager::invalidateAll("user_{$userId}"); |
| | | $this->cache->delete(self::CACHE_QUEUE_INFO); |
| | | $this->cache->forget($userId); |
| | | } |
| | | } |