indexex.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. {
  22. foreach ($list_key as $key) {
  23. $content = $worker->pop($key, time());
  24. if (empty($content)) continue;
  25. $method = key($content);
  26. $arg = current($content);
  27. $model_queue->$method($arg);
  28. echo date('Y-m-d H:i:s',time()).' '.$method."\n";
  29. // $content['time'] = date('Y-m-d H:i:s',time());
  30. // print_R($content);
  31. // echo "\n";
  32. flush();
  33. ob_flush();
  34. }
  35. }
  36. sleep(1);
  37. }
  38. }
  39. }