jsproxy/lua/g.lua

37 lines
505 B
Lua
Raw Normal View History

2019-04-29 09:51:22 +00:00
local _M = {}
local traff = ngx.shared.traff
local nReq = 0
function _M.inc()
nReq = nReq + 1
end
function _M.syn()
traff:incr('nReq', nReq)
nReq = 0
end
function _M.update()
local nReq = traff:get('nReq')
traff:set('nReq', 0)
return nReq
end
function _M.getStat()
return traff:get('stat')
end
function _M.setStat(stat)
return traff:set('stat', stat)
end
function _M.reset()
if traff:get('nReq') == nil then
traff:add('nReq', 0)
traff:add('stat', '')
end
end
return _M