CodeIgniter RESTful, async / background process

前端 未结 4 1761
悲&欢浪女
悲&欢浪女 2020-12-11 06:18

I\'m using codeIgniter RESTful API (https://github.com/philsturgeon/codeigniter-restserver) that return information (json format) to my android/iphone app.

There are

4条回答
  •  难免孤独
    2020-12-11 07:00

    Since PHP doesn't natively support threads or asynchronus function calls you will have to use a kindof hacky solution. Have a look at my question here: PHP file_get_contents() follow Content-length header

    The Solution is to send a Connection: Close and Content-Length header, then make the client to be aware of these headers (see link above). In case of curl for example the connection will be closed as soon as the Content-Length is reached, but your PHP Script still runs "in the background" so you can start time consuming operations then.

    Kind regards,

    Stefan

    P.S. If the Script takes really long to execute, make sure that the PHP max exection time doesn't get in your way

提交回复
热议问题