PHP: How to return information to a waiting script and continue processing

后端 未结 7 2053
暖寄归人
暖寄归人 2021-02-09 22:14

Suppose there are two scripts Requester.php and Provider.php, and Requester requires processing from Provider and makes an http request to it (Provider.php?data=\"data\"). In th

7条回答
  •  太阳男子
    2021-02-09 22:46

    Split the Provider in two: ProviderCore and ProviderInterface. In ProviderInterface just do the "quick and easy" part, also save a flag in database that the recent request hasn't been processed yet. Run ProviderCore as a cron job that searches for that flag and completes processing. If there's nothing to do, ProviderCore will terminate and retry in (say) 2 minutes.

提交回复
热议问题