0

如何找出单例缓存中的内容?我试图找出为什么缓存永远不会被命中?它总是执行_M.introspect_access_token_req

local cache_id = "ati:" .. access_token
local res, err = singletons.cache:get(cache_id, { ttl = _M.conf.token_cache_time },
                _M.introspect_access_token_req, access_token)
function _M.introspect_access_token_req(access_token)
    local httpc = http:new()

    ngx.log(ngx.DEBUG, "APIGW-PLUGIN-ATI : Calling External service for Introspection ...")

    local res, err = httpc:request_uri(introspection_endpoint, {
        method = "POST",
        ssl_verify = false,
        body = "token_type_hint=access_token&token=" .. access_token .. "&client_id=" .. _M.conf.client_id .. "&client_secret=" .. _M.conf.client_secret,
        headers = { ["Content-Type"] = "application/x-www-form-urlencoded", }
    })

    ngx.log(ngx.DEBUG, "APIGW-PLUGIN-ATI : External service called")

    if not res then
        return { status = 0 }
    end
    if res.status ~= 200 then
        return { status = res.status }
    end
    return { id = "ati:" .. access_token, status = res.status, body = res.body }
end
4

0 回答 0