mirror of
https://github.com/EtherDream/jsproxy
synced 2024-11-22 18:50:48 +00:00
37 lines
505 B
Lua
37 lines
505 B
Lua
|
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
|