Spring Boot 2 Caching OAuth 2.0 Token until tokens TTL

Hi there,

Our app is SpringBoot 2 integrated with Auth0 where our end users get access_token each time using client_id and client_secret.

Now, we came up with new requirement of caching the token for the life (TTL) of access_token so that we don’t need to create access_token on each request which will save the round trip and in-turn improves performance and User experience.
PS- our requirement so far is only to support in-memory cache instead of external caching or db caching.

I thought of using SpringBoot Caching but the challenge is evicting cached token when it passes TTL of each item. There is not out of box feature available so far for Generic/Simple CacheManager of Spring lib.

The ask here is -
Auth0 provides Auth0-SpringBoot 2 library, does it provide caching mechanism out of box with TTL??
If there are multiple options, what is the recommended approach for caching?

Many thanks in advance!!!
Yogesh.

1 Like