新增trie tree缓存命令
This commit is contained in:
parent
cbfcce919f
commit
96f04545db
@ -2,7 +2,9 @@
|
|||||||
namespace catcher;
|
namespace catcher;
|
||||||
|
|
||||||
use catcher\command\publish\WechatCommand;
|
use catcher\command\publish\WechatCommand;
|
||||||
|
use catcher\command\TestCommand;
|
||||||
use catcher\command\Tools\BackupCommand;
|
use catcher\command\Tools\BackupCommand;
|
||||||
|
use catcher\command\Tools\CacheTrieCommand;
|
||||||
use catcher\command\Tools\CompressPackageCommand;
|
use catcher\command\Tools\CompressPackageCommand;
|
||||||
use catcher\command\CreateModuleCommand;
|
use catcher\command\CreateModuleCommand;
|
||||||
use catcher\command\install\InstallProjectCommand;
|
use catcher\command\install\InstallProjectCommand;
|
||||||
@ -71,7 +73,8 @@ class CatchAdminService extends Service
|
|||||||
ExportDataCommand::class,
|
ExportDataCommand::class,
|
||||||
MakeMenuCommand::class,
|
MakeMenuCommand::class,
|
||||||
ExcelTaskCommand::class,
|
ExcelTaskCommand::class,
|
||||||
WechatCommand::class
|
WechatCommand::class,
|
||||||
|
CacheTrieCommand::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
39
extend/catcher/command/Tools/CacheTrieCommand.php
Normal file
39
extend/catcher/command/Tools/CacheTrieCommand.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace catcher\command\Tools;
|
||||||
|
|
||||||
|
use catchAdmin\system\model\SensitiveWord;
|
||||||
|
use catcher\library\Trie;
|
||||||
|
use think\console\Command;
|
||||||
|
use think\console\Input;
|
||||||
|
use think\console\Output;
|
||||||
|
|
||||||
|
class CacheTrieCommand extends Command
|
||||||
|
{
|
||||||
|
protected $table;
|
||||||
|
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
// 指令配置
|
||||||
|
$this->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user