argument('identifier'); try { // 모듈 디렉토리 스캔 및 로드 $this->moduleManager->loadModules(); $clearedCount = 0; if ($identifier) { // 특정 모듈 캐시 삭제 $this->info(__('modules.commands.cache_clear.clearing_single', ['module' => $identifier])); // 모듈이 존재하는지 확인 $module = $this->moduleManager->getModule($identifier); if (! $module) { $this->error('❌ '.__('modules.not_found', ['module' => $identifier])); return Command::FAILURE; } $clearedCount = $this->clearModuleCache($identifier); $this->info('✅ '.__('modules.commands.cache_clear.success_single', [ 'module' => $identifier, 'count' => $clearedCount, ])); } else { // 모든 모듈 캐시 삭제 $this->info(__('modules.commands.cache_clear.clearing_all')); // 전체 모듈 캐시 키 삭제 $cacheKeys = [ 'modules.all', 'modules.active', 'modules.installed', ]; foreach ($cacheKeys as $key) { if ($this->cache->forget($key)) { $clearedCount++; } } // 각 모듈별 캐시 삭제 $allModules = $this->moduleManager->getAllModules(); foreach ($allModules as $moduleName => $module) { $clearedCount += $this->clearModuleCache($module->getIdentifier()); } // 모듈 프론트엔드 병합 번들 파일 삭제 (캐시 키 forget 만으로는 미삭제) $clearedCount += $this->bundleService->clearBundles('module'); $this->info('✅ '.__('modules.commands.cache_clear.success_all', ['count' => $clearedCount])); } Log::info('모듈 캐시 삭제 완료', [ 'module' => $identifier ?? 'all', 'count' => $clearedCount, ]); return Command::SUCCESS; } catch (\Exception $e) { $this->error('❌ '.$e->getMessage()); Log::error('모듈 캐시 삭제 실패', [ 'module' => $identifier ?? 'all', 'error' => $e->getMessage(), ]); return Command::FAILURE; } } /** * 특정 모듈의 캐시를 삭제합니다. */ private function clearModuleCache(string $identifier): int { $clearedCount = 0; // 모듈별 캐시 키 $cacheKeys = [ "module.config.{$identifier}", "module.info.{$identifier}", "module.routes.{$identifier}", "module.permissions.{$identifier}", "module.menus.{$identifier}", ]; foreach ($cacheKeys as $key) { if ($this->cache->forget($key)) { $clearedCount++; } } return $clearedCount; } }