Skip to main content

Caching

The sttp-oauth2 library comes with CachingAccessTokenProvider and CachingTokenIntrospection - interfaces that allow caching the responses provided by the OAuth2 provider. Both of those require an implementation of the ExpiringCache algebra, defined as follows:

trait ExpiringCache[F[_], K, V] {
def get(key: K): F[Option[V]]
def put(key: K, value: V, expirationTime: Instant): F[Unit]
def remove(key: K): F[Unit]
}

As the user of the library you can either choose to implement your own cache mechanism, or go for one of the provided:

ClassDescriptionImport module
CatsRefExpiringCacheSimple Cats Effect 3 Ref based implementation. Good enough for CachingAccessTokenProvider, but for CachingTokenIntrospection it's recommended to use an instance which better handles memory (this instance does not periodically remove expired entries)"com.ocadotechnology" %% "sttp-oauth2-cache-cats" % "0.17.0"
CatsRefExpiringCacheSimple Cats Effect 2 Ref based implementation. Good enough for CachingAccessTokenProvider, but for CachingTokenIntrospection it's recommended to use an instance which better handles memory (this instance does not periodically remove expired entries)"com.ocadotechnology" %% "sttp-oauth2-cache-ce2" % "0.17.0"
ScalacacheExpiringCacheImplementation based on https://github.com/cb372/scalacache"com.ocadotechnology" %% "sttp-oauth2-cache-scalacache" % "0.17.0"
MonixFutureCacheFuture based implementation powered by Monix"com.ocadotechnology" %% "sttp-oauth2-cache-future" % "0.17.0"