...
|
...
|
@@ -16,6 +16,9 @@ function M:switch() |
|
|
|
|
|
if method == "query" then
|
|
|
local percentage = lua_context.lua_conf_cache:get("switch:percentage")
|
|
|
if not percentage then
|
|
|
percentage = '0'
|
|
|
end
|
|
|
ngx.say(percentage)
|
|
|
ngx.exit(ngx.HTTP_OK)
|
|
|
|
...
|
...
|
@@ -35,13 +38,15 @@ function M:switch() |
|
|
lua_context.lua_conf_cache:set("switch:uid", uid)
|
|
|
ngx.exit(ngx.HTTP_OK)
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
function M:init()
|
|
|
return lua_context.lua_conf_cache:set("switch:percentage", 0)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
--- reset all
|
|
|
if method == "reset" then
|
|
|
lua_context.lua_conf_cache:delete("switch:uid")
|
|
|
lua_context.lua_conf_cache:delete("switch:percentage")
|
|
|
ngx.exit(ngx.HTTP_OK)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
function M:get_percentage()
|
|
|
local per = lua_context.lua_conf_cache:get("switch:percentage")
|
...
|
...
|
|