View Source PrimaAuth0Ex.TokenProvider.ProbabilisticRefreshStrategy (prima_auth0_ex v0.4.4)

Implementation of PrimaAuth0Ex.TokenProvider.RefreshStrategy that relies on a probabilistic approach to decide whether to refresh a token.

The reason why a probabilistic approach is desirable is that multiple instances may share a common cache of tokens. If all of them used the same deterministic approach to decide when to refresh tokens, the likelihood of concurrent regeneration of the cached token would be higher.

This strategy defines a "refresh window", which is a time span in the lifespan of a token when the refresh may happen (e.g., "from 50% to 75% of the life of the token"). The refresh time will be a random time in the refresh window.

The "refresh window" can be customized from config as follows

config :prima_auth0_ex, :client,

min_token_duration: 0.5,
max_token_duration: 0.75,