diff --git a/extend/catcher/CatchAdminService.php b/extend/catcher/CatchAdminService.php index b04e73b..26408f7 100644 --- a/extend/catcher/CatchAdminService.php +++ b/extend/catcher/CatchAdminService.php @@ -2,7 +2,9 @@ namespace catcher; use catcher\command\publish\WechatCommand; +use catcher\command\TestCommand; use catcher\command\Tools\BackupCommand; +use catcher\command\Tools\CacheTrieCommand; use catcher\command\Tools\CompressPackageCommand; use catcher\command\CreateModuleCommand; use catcher\command\install\InstallProjectCommand; @@ -71,7 +73,8 @@ class CatchAdminService extends Service ExportDataCommand::class, MakeMenuCommand::class, ExcelTaskCommand::class, - WechatCommand::class + WechatCommand::class, + CacheTrieCommand::class, ]); } /** diff --git a/extend/catcher/command/Tools/CacheTrieCommand.php b/extend/catcher/command/Tools/CacheTrieCommand.php new file mode 100644 index 0000000..25d5f7c --- /dev/null +++ b/extend/catcher/command/Tools/CacheTrieCommand.php @@ -0,0 +1,39 @@ +setName('cache:trie') + ->setDescription('cache trie'); + } + + protected function execute(Input $input, Output $output) + { + $words = SensitiveWord::cursor(); + + $trie = new Trie(); + + foreach ($words as $word) { + $trie->add($word->word); + } + + if ($trie->cached()) { + $output->info('trie cached'); + } else { + $output->error('trie cached failed'); + } + } +}