<legend id='s7evJ'><style id='s7evJ'><dir id='s7evJ'><q id='s7evJ'></q></dir></style></legend>
  • <i id='s7evJ'><tr id='s7evJ'><dt id='s7evJ'><q id='s7evJ'><span id='s7evJ'><b id='s7evJ'><form id='s7evJ'><ins id='s7evJ'></ins><ul id='s7evJ'></ul><sub id='s7evJ'></sub></form><legend id='s7evJ'></legend><bdo id='s7evJ'><pre id='s7evJ'><center id='s7evJ'></center></pre></bdo></b><th id='s7evJ'></th></span></q></dt></tr></i><div id='s7evJ'><tfoot id='s7evJ'></tfoot><dl id='s7evJ'><fieldset id='s7evJ'></fieldset></dl></div>
      <bdo id='s7evJ'></bdo><ul id='s7evJ'></ul>

      <tfoot id='s7evJ'></tfoot>

      1. <small id='s7evJ'></small><noframes id='s7evJ'>

      2. PHP- 需要一个 cron 用于用户注册的后台处理...(或 fork 进程)

        PHP- Need a cron for back site processing on user signup... (or fork process)(PHP- 需要一个 cron 用于用户注册的后台处理...(或 fork 进程))
      3. <small id='4UpKF'></small><noframes id='4UpKF'>

          <i id='4UpKF'><tr id='4UpKF'><dt id='4UpKF'><q id='4UpKF'><span id='4UpKF'><b id='4UpKF'><form id='4UpKF'><ins id='4UpKF'></ins><ul id='4UpKF'></ul><sub id='4UpKF'></sub></form><legend id='4UpKF'></legend><bdo id='4UpKF'><pre id='4UpKF'><center id='4UpKF'></center></pre></bdo></b><th id='4UpKF'></th></span></q></dt></tr></i><div id='4UpKF'><tfoot id='4UpKF'></tfoot><dl id='4UpKF'><fieldset id='4UpKF'></fieldset></dl></div>

            • <bdo id='4UpKF'></bdo><ul id='4UpKF'></ul>
              • <tfoot id='4UpKF'></tfoot>
                  <tbody id='4UpKF'></tbody>
                1. <legend id='4UpKF'><style id='4UpKF'><dir id='4UpKF'><q id='4UpKF'></q></dir></style></legend>
                2. 本文介绍了PHP- 需要一个 cron 用于用户注册的后台处理...(或 fork 进程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  每当有新用户在我的网站上注册时,我都想进行一些预处理以缩短他们将来的搜索时间.这涉及 30 到 2 分钟的处理时间.显然,当他们在注册时单击提交按钮时,我无法执行此操作...或在他们访问的任何 PHP 页面上.但是,我希望在他们注册后的 5 分钟内(或更短时间)完成此操作.

                  Whenever a new user signs up on my site, I want to do some pre-processing to shorten their searches in the future. This involves anywhere from 30 to 2 minutes processing time. Obviously I cannot do this when they click the submit button on signup... or on any PHP page they visit. However, I would like this done within 5 minutes of them signing up (or less).

                  Cron 路由我认为这需要在 cron 工作中进行,如果是这样,我应该如何设置 cron 工作?如果是这样,我的 cron 线应该每 2 分钟运行一次,我如何确保相同的 cron 作业不会与下一个重叠?

                  Cron Route I THINK this needs to be in a cron job, and if so, how should I setup the cron job? If so, what should my cron line look like to run every 2 minutes, and how can I insure that I don't have the same cron job overlapping the next?

                  事件/分叉路线 - 首选如果我可以在不中断用户体验的情况下向我的服务器抛出一些事件或从用户注册(而不是 cron 作业)中分出一个过程,我该怎么做?

                  Event/Fork Route - Preferred If I can possibly throw some event to my server without disrupting my users experience or fork a process off of the users signup (instead of a cron job) how could I do this?

                  推荐答案

                  我不推荐这两种解决方案.

                  I would recommend neither solution.

                  相反,您最好使用一个长时间运行的进程(守护进程),它从 消息队列.如果这是您的首选方法,则消息队列本身可以脱离数据库.

                  Instead, you would be best off with a long running process (daemon) that gets its jobs from a message queue. The message queue itself could be off a database if that is your preferred method.

                  您将作业的标识符发布到您的数据库中,然后一个长时间运行的进程将不时遍历它们并对其采取行动.

                  You will post an identifier for the job to your database, and then a long running process will iterate through them once in a while and act upon them.

                  这很简单:

                  <?php
                  while(true) {
                     jobs = getListOfJobsFromDatabase();  // get the jobs from the databbase
                     foreach (jobs as job) {
                        processAJob(job); // do whatever needs to be done for the job
                        deleteJobFromDatabase(job); //remember to delete the job once its done!
                     }
                     sleep(60); // sleep for a while so it doesnt thrash your database when theres nothing to do
                  }
                  ?>
                  

                  然后从命令行运行该脚本.

                  And just run that script from the command line.

                  与 cron 作业相比,这样做的好处是您不会遇到竞争条件.

                  The benefits of this over a cron job are that you wont get a race condition.

                  您可能还想将作业的实际处理分叉出来,以便可以并行完成,而不是按顺序处理.

                  You may also want to fork off the actually processing of the jobs so many can be done in parallel, rather than processing sequentially.

                  这篇关于PHP- 需要一个 cron 用于用户注册的后台处理...(或 fork 进程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='2wQIc'></small><noframes id='2wQIc'>

                  <i id='2wQIc'><tr id='2wQIc'><dt id='2wQIc'><q id='2wQIc'><span id='2wQIc'><b id='2wQIc'><form id='2wQIc'><ins id='2wQIc'></ins><ul id='2wQIc'></ul><sub id='2wQIc'></sub></form><legend id='2wQIc'></legend><bdo id='2wQIc'><pre id='2wQIc'><center id='2wQIc'></center></pre></bdo></b><th id='2wQIc'></th></span></q></dt></tr></i><div id='2wQIc'><tfoot id='2wQIc'></tfoot><dl id='2wQIc'><fieldset id='2wQIc'></fieldset></dl></div>
                    • <tfoot id='2wQIc'></tfoot>
                        <tbody id='2wQIc'></tbody>

                        <legend id='2wQIc'><style id='2wQIc'><dir id='2wQIc'><q id='2wQIc'></q></dir></style></legend>

                          <bdo id='2wQIc'></bdo><ul id='2wQIc'></ul>