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
 
原文地址:https://www.cnblogs.com/justart/p/12388811.html