Have a look at Guava <https://github.com/google/guava> caching:
http://guava-libraries.googlecode.com/files/JavaCachingwithGuava.pdf In particular, look at the "Automatic Refresh" section. You'd implement a custom loader for the cache, set an expiry time of just short of an hour, and always get the token from the cache. There's support for getting a "stale" token while the token refresh is happening. By setting the expiry time just short of an hour you can ensure that the stale version is always active while you proactively fetch an updated token to take its place before it hits its expiration. That way you don't introduce any user-facing latency by requiring a user request to wait for a token refresh (unless token refresh requires some property of a user-facing request). Ryan On Thu, May 12, 2016 at 11:37 AM Ali Akhtar <[email protected]> wrote: > Thanks, but it does need to be modified. The token only lasts for an hour > and then needs to be replaced with a new token. My question was, if my > implemention of the getToken() method will work for the purpose of > regenerating it when needed. > > -- > You received this message because you are subscribed to the Google Groups > "dropwizard-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
