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.

46 lines
828 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. public function execWithoutTask($method,...$args)
  22. {
  23. $result = $this->client()->__call($method,$args);
  24. return $result;
  25. }
  26. protected function client(){
  27. if ($this->ss instanceof SimpleSSDB) {
  28. return $this->ss;
  29. }
  30. $this->ss = new SimpleSSDB(env('SSDB_HOST'), env('SSDB_PORT'));
  31. $this->ss->auth(env('SSDB_AUTH'));
  32. return $this->ss;
  33. }
  34. }