info('Clearing cities cache...'); try { // Get the Redis connection used by cache $redis = Cache::getStore()->getRedis(); $prefix = config('cache.prefix'); // Get all cache keys that match our patterns $patterns = [ 'wikipedia:*', 'opentripmap:*', 'overpass:*', ]; $clearedCount = 0; foreach ($patterns as $pattern) { $fullPattern = $prefix . $pattern; $keys = $redis->keys($fullPattern); foreach ($keys as $key) { // Remove the prefix to get the actual cache key $cacheKey = str_replace($prefix, '', $key); Cache::forget($cacheKey); $clearedCount++; } } if ($clearedCount === 0) { $this->comment('No cache entries found to clear.'); } else { $this->info("Successfully cleared {$clearedCount} cache entries."); } return Command::SUCCESS; } catch (\Exception $e) { $this->error("Error clearing cache: " . $e->getMessage()); return Command::FAILURE; } } }