I’m writing a custom kong plugin, where we need to cache an access token retrived using basic authorization till a specific TTL and invalidate it entry after that TTL.
(Caching backed by entities is not an option for me because of various reasons, I directly need to persist the values in cache).
Can I use mlcache defined/maintained by kong (in cache.lua) and modify the ttl defined to fit my requirement without effecting other parameters such as ipc, resty_rock_ops ?
If yes, in which phase of request context should I put this overriding logic ?
My current code looks like this :
local lru = singletons.cache.mlcache.lru lru:set(authorization_code, access_token)
I’m not able to specify the ttl for that entry.
Why Custom TTL needed : Because the token will expire after that TTL we need to hit other 3rd party webservice to get new access token. Then idea behind caching is to remove overhead of 3rd party call till the token is valid.
Thanks in advance.