查看 kong.singletons.cache 中有什么? 孔 0.11.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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)