clearCache.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\command;
  13. use think\console\Command;
  14. use think\console\Input;
  15. use think\console\input\Argument;
  16. use think\console\Output;
  17. use think\facade\Cache;
  18. class clearCache extends Command
  19. {
  20. protected function configure()
  21. {
  22. // 指令配置
  23. $this->setName('clearCache')
  24. ->addArgument('cacheType',Argument::OPTIONAL, 'php think menu [1] / [2]')
  25. ->setDescription('清楚缓存:php think clearCache 1');
  26. }
  27. /**
  28. * 清楚缓存执行
  29. * @param Input $input
  30. * @param Output $output
  31. * @return int|void|null
  32. * @author Qinii
  33. * @day 4/24/22
  34. */
  35. protected function execute(Input $input, Output $output)
  36. {
  37. $type = $input->getArgument('cacheType');
  38. $tag = ['sys_login_freeze','mer_login_freeze'];
  39. $msg = '';
  40. switch ($type) {
  41. case 0:
  42. $msg = '平台登录限制';
  43. $tag = 'sys_login_freeze';
  44. break;
  45. case 1:
  46. $msg = '商户登录限制';
  47. $tag = 'mer_login_freeze';
  48. break;
  49. }
  50. Cache::tag($tag)->clear();
  51. $output->writeln('清楚缓存'.$msg);
  52. }
  53. }