SystemService.php 712 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Service;
  4. use App\Master\Enum\PassportEnum;
  5. use Hyperf\Di\Annotation\Inject;
  6. use Hyperf\Cache\Listener\DeleteListenerEvent;
  7. use Psr\EventDispatcher\EventDispatcherInterface;
  8. /**
  9. * Author:Panda
  10. * Email:joeyoung0314@qq.com
  11. * Class SystemService
  12. * @package App\Service
  13. */
  14. class SystemService
  15. {
  16. #[Inject]
  17. protected EventDispatcherInterface $dispatcher;
  18. /**
  19. * 清除用户信息缓存
  20. *
  21. * @param int $user_id
  22. * @return bool
  23. */
  24. public function flushCache(int $user_id): bool
  25. {
  26. $this->dispatcher->dispatch(new DeleteListenerEvent(PassportEnum::USER_INFO, ['user_id' => $user_id]));
  27. return true;
  28. }
  29. }