码迷,mamicode.com
首页 > 其他好文 > 详细

resty的理解

时间:2020-03-01 12:39:57      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:sleep   style   --   tom   spawn   read   cti   isp   UNC   

无头的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
 

resty的理解

标签:sleep   style   --   tom   spawn   read   cti   isp   UNC   

原文地址:https://www.cnblogs.com/justart/p/12388811.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!