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:
As the user of the library you can either choose to implement your own cache mechanism, or go for one of the provided:
Class | Description | Import module |
---|---|---|
ZioRefExpiringCache | Simple ZIO 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) | "org.polyvariant" %% "sttp-oauth2-cache-zio" % "0.19.2" |
CatsRefExpiringCache | Simple 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) | "org.polyvariant" %% "sttp-oauth2-cache-cats" % "0.19.2" |
CatsRefExpiringCache | Simple 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) | "org.polyvariant" %% "sttp-oauth2-cache-ce2" % "0.19.2" |
ScalacacheExpiringCache | Implementation based on https://github.com/cb372/scalacache | "org.polyvariant" %% "sttp-oauth2-cache-scalacache" % "0.19.2" |
MonixFutureCache | Future based implementation powered by Monix | "org.polyvariant" %% "sttp-oauth2-cache-future" % "0.19.2" |