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. if (ob_get_level()) ob_end_clean();
  14. $model_queue = Model('queue',BASE_PATH);
  15. $worker = new QueueServer();
  16. while (true)
  17. {
  18. $list_key = $worker->scan();
  19. if (!empty($list_key) && is_array($list_key)) {
  20. foreach ($list_key as $key) {
  21. $content = $worker->pop($key);
  22. if (empty($content)) continue;
  23. $method = key($content);
  24. $arg = current($content);
  25. $model_queue->$method($arg);
  26. echo date('Y-m-d H:i:s',time()).' '.$method."\n";
  27. // $content['time'] = date('Y-m-d H:i:s',time());
  28. // print_R($content);
  29. // echo "\n";
  30. flush();
  31. ob_flush();
  32. }
  33. }
  34. sleep(1);
  35. }
  36. }
  37. }