nginx的 say和print的异步输出

server {

listen 80;

location /test {

content_by_lua_block {

ngx.say("hello")

ngx.sleep(3)

ngx.say("the world")

}

}

location /test2 {

content_by_lua_block {

ngx.say("hello")

ngx.flush() -- 显式的向客户端刷新响应输出

ngx.sleep(3)

ngx.say("the world")

}

}

}

想知道,对于/test来说,hello和 the world 一起输出,这不就是同步了嘛,哪里叫异步呀?

回答

nginx-module#ngxprint" rel="nofollow noreferrer">ngxxprint:

This is an asynchronous call and will return immediately without waiting for all the data to be written into the system send buffer.

异步是指函数不会等写入完成再返回。

以上是 nginx的 say和print的异步输出 的全部内容, 来源链接: utcz.com/a/38361.html

回到顶部