Beanstalk.php 669 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace crmeb\utils;
  3. use Pheanstalk\Pheanstalk;
  4. /**
  5. * Beanstalkd client
  6. */
  7. class Beanstalk {
  8. protected static $inst;
  9. protected $talk;
  10. protected $config = [];
  11. protected function __construct()
  12. {
  13. $this->config = config('beanstalk');
  14. $this->talk = Pheanstalk::create($this->config['addr'], $this->config['port']);
  15. }
  16. public static function instance()
  17. {
  18. if (is_null(self::$inst)) {
  19. self::$inst = new static();
  20. }
  21. return self::$inst;
  22. }
  23. public static function __callStatic($name, $arguments)
  24. {
  25. return self::instance()->talk->{$name}(...$arguments);
  26. }
  27. }