local degrade_get_percent=function(cache,servername,location)
local prefix=""
local deg_key=""
local percent,err
for i=1,#location do
if location:sub(i,i)=='/' then
prefix=location:sub(1,i)
if #prefix>1 then --escape the last '/',of coure except for single '/'
prefix=prefix:sub(1,#prefix-1)
end
deg_key=table.concat({degrade_policy_prefix,servername,prefix},degrade_concat_symbol)
percent,err=cache:get(deg_key)
if percent then
return percent
--elseif err then
-- ngx.log(ngx.ERR,"cache get:",err)
end
end
end
deg_key=table.concat({degrade_policy_prefix,servername,location},degrade_concat_symbol)
percent,err=cache:get(deg_key)
if percent then
return percent
elseif err then
ngx.log(ngx.ERR,"cache get:",err)
return nil,err
end
return nil --Not set percent for this request
end