Hello!
2013/3/5 ristona.hua:
> location /test {
> content_by_lua '
> local fixed_args, count = ngx.re.sub( ngx.var.args, "&?_=[0-9]+", "" );
> if count > 0 then
> ngx.exec("/notice", fixed_args);--我希望这步不需等待子请求执行完毕,立即执行后面的语句。不知有什么方法不?
你把概念搞错了,ngx.exec 发起的是“内部跳转”(internal redirection),而不是“子请求”(subrequest)。
在 ngx_lua 中,子请求是通过 ngx.location.capture 或者 ngx.location.capture_multi 来发起的:
http://wiki.nginx.org/HttpLuaModule#ngx.location.capture
特别地,如果你希望子请求异步执行,你需要使用 ngx.thread.spawn 来创建自己的“轻量级线程”,见:
http://wiki.nginx.org/HttpLuaModule#ngx.thread.spawn
关于“子请求”、“内部跳转”等 Nginx 基础概念的讨论,请参见我的 Nginx 系列教程,以避免犯低级错误:
http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
Best regards,
-agentzh