参考官方 init_worker_by_lua 用例,在ngx.timer.at新启动的function里面去做你需要的即可。
init_worker_by_lua '
local delay = 3 -- in seconds
local new_timer = ngx.timer.at
local log = ngx.log
local ERR = ngx.ERR
local check
check = function(premature)
if not premature then
-- do your routine work in here
-- ... ...
end
end
local ok, err = new_timer(delay, check)
if not ok then
log(ERR, "failed to create timer: ", err)
return
end
';
On Friday, October 31, 2014 11:51:13 AM UTC+8, xiati...@gmail.com wrote:
章大哥,论坛的大神好:
现在我有个疑问,我想在nginx启动的时候把mysql的数据全部加载到share dict,也就是本地内存中,请问我应该怎么做?