一个不太常用的php异步调用方式 浏览次数:271 日期:2020-07-18 10:15:00 php异步调用基本上都是结合消息队列来实现的,但是有时候现实是很骨感的,服务端没有安装消息队列服务,那这时候怎么实现异步呢;还有一个策略是结合存储中间件+crontab轮询,但是这难免会有时间差的影响,不能实时触发,笔者就遇到了这种困境,项目早期没有消息队列的引入,又要实时触发,要优化当前请求的效率,怎么办呢,就引入了今天的一个不太常用的异步方式。 ### 异步好处 - 解耦代码 - 减少客户端的响应时间,提高吞吐量 ### 代码 ```php passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server => passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server ``` 如果禁用的话,使用函数会出现错误 ```shell PHP Warning: popen() has been disabled for security reasons PHP Warning: pclose() expects parameter 1 to be resource, null given in ``` 最后更新时间为: 8个月前 (2020-07-18 10:15:00)