common.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. \think\Console::addDefaultCommands([
  12. "think\\queue\\command\\Work",
  13. "think\\queue\\command\\Restart",
  14. "think\\queue\\command\\Listen",
  15. "think\\queue\\command\\Subscribe"
  16. ]);
  17. if (!function_exists('queue')) {
  18. /**
  19. * 添加到队列
  20. * @param $job
  21. * @param string $data
  22. * @param int $delay
  23. * @param null $queue
  24. */
  25. function queue($job, $data = '', $delay = 0, $queue = null)
  26. {
  27. if ($delay > 0) {
  28. \think\Queue::later($delay, $job, $data, $queue);
  29. } else {
  30. \think\Queue::push($job, $data, $queue);
  31. }
  32. }
  33. }