resty的理解

无头的openresty,去掉了守护运行,把代码加载到
init_worker_by_lua directive处执行
run in the context of ngx.timer callback里面
resty --shdict='dogs 1m' -e 'local dict = ngx.shared.dogs dict:set("Tom", 56) print(dict:get("Tom"))'


time resty -e 'local ths = {}
                 for i = 1, 3 do
                     ths[i] = ngx.thread.spawn(function ()
                                  ngx.sleep(3) ngx.say("done ", i)
                              end)
                 end
                 for i = 1, #ths do ngx.thread.wait(ths[i]) end'
done 1
done 2
done 3

real 0m3.073s
user 0m0.053s
sys 0m0.015s
 
posted @ 2020-03-01 11:33  FromScratch  阅读(377)  评论(0编辑  收藏  举报