hi all
我有一个需求: 我需求循环去请求一个location, 获取每次的响应进行拼接成一个大文件。
如下:
local interval = 5
local cur = 0
local end = 1000
while cur <= end do
local res = ngx.location.capture(string.format("/live/%d.block", cur))
if (res.status == 200) then
ngx.print(string.sub(res.body, 1024))
ngx.flush()
end
ngx.sleep(1)
cur = cur + interval
end
这样做有一个问题是发现 ngx.location.capture效率很差, 求助各位,有没有什么优化方案? 谢谢!
ngx_lua版本 0.9.2
--
Best Regards,
Harold Miao