clearCache.php 2.6 KB

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