How to delete kong caching after sometime?

This is my below code. Cache is not clear even after data has been deleted from database.

local token_cache_key = singletons.dao.test_oauth2_client_auth_tokens:cache_key(access_token)
token, err = singletons.cache:get(token_cache_key, nil,
            load_token_into_memory, ngx.ctx.api,

DB add code.

local function generate_token(api, client_id, access_token, expiration)
    local token, err = singletons.dao.test_oauth2_client_auth_tokens:insert({
        api_id =,
        client_id = client_id,
        expires_in = expiration,
        access_token = access_token
    }, {ttl = expiration or nil})

    if err then
        return responses.send_HTTP_INTERNAL_SERVER_ERROR(err)

    return {
        client_id = client_id,
        access_token = token.access_token,
        expires_in = expiration or nil,

Please suggest me any solution?

Already answered in How to delete caching after some specified time?

1 Like

Closed and marked as duplicate of How to delete caching after some specified time?.

1 Like