index.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * 队列
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class indexControl
  11. {
  12. public function queueOp()
  13. {
  14. if (ob_get_level()) ob_end_clean();
  15. $model_queue = Model('queue',BASE_PATH);
  16. $worker = new QueueServer();
  17. while (true)
  18. {
  19. $list_key = $worker->scan();
  20. if (!empty($list_key) && is_array($list_key)) {
  21. foreach ($list_key as $key) {
  22. $content = $worker->pop($key, time());
  23. if (empty($content)) continue;
  24. $method = key($content);
  25. $arg = current($content);
  26. $model_queue->$method($arg);
  27. echo date('Y-m-d H:i:s',time()).' '.$method."\n";
  28. // $content['time'] = date('Y-m-d H:i:s',time());
  29. // print_R($content);
  30. // echo "\n";
  31. flush();
  32. ob_flush();
  33. }
  34. }
  35. sleep(1);
  36. }
  37. }
  38. }