You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
677 B

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\TaskWorker;
  4. use Hyperf\Utils\ApplicationContext;
  5. use App\Libs\SimpleSSDB;
  6. use Hyperf\Task\Annotation\Task;
  7. class SSDBTask
  8. {
  9. /**
  10. * @var SimpleSSDB
  11. */
  12. public $ss = null;
  13. /**
  14. * @Task
  15. */
  16. public function exec($method,...$args)
  17. {
  18. $result = $this->client()->__call($method,$args);
  19. return $result;
  20. }
  21. protected function client(){
  22. if ($this->ss instanceof SimpleSSDB) {
  23. return $this->ss;
  24. }
  25. $this->ss = new SimpleSSDB(env('SSDB_HOST'), env('SSDB_PORT'));
  26. $this->ss->auth(env('SSDB_AUTH'));
  27. return $this->ss;
  28. }
  29. }