Skip to content

Commit

Permalink
Document new caching behaviors (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaeIsBad authored Nov 22, 2023
1 parent 8ba0336 commit 0e8e644
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,23 @@ config :prima_auth0_ex, :server,
missing_auth_header_log_level: :warn
```

### Redis & caching
## Caching

Clients can be configured to use caching through Redis. To use cachine you can use the following configuration:
Auth0_ex clients can cache tokens. By default the MemoryCache is used, which should allow tokens to be shared across erlang nodes. This behavior can be changed by setting `:prima_auth0_ex, :token_cache`

```elixir
# Disable caching of tokens
config :prima_auth0_ex, :token_cache, NoopCache
```

Note that right now caching is assumed to be all-or-nothing with respect to multiple clients i.e. either all clients use caching or none of them do. If you have a use case that is not supported by this please contact us so that we can see what we can do.

### Redis
Clients can be configured to use caching through Redis. To use caching you can use the following configuration:

```elixir
config :prima_auth0_ex, :token_cache, EncryptedRedisTokenCache

config :prima_auth0_ex, :redis,
# Enables cache on redis for tokens obtained from Auth0. Defaults to false.
enabled: true,
Expand All @@ -117,9 +129,7 @@ config :prima_auth0_ex, :redis,
ssl_allow_wildcard_certificates: false
```

Note that right now caching is assumed to be all-or-nothing with respect to multiple clients i.e. either all clients use caching or none of them do. If you have a use case that is not supported by this please contact us so that we can see what we can do.

### Operational requirements
#### Operational requirements

To cache tokens on Redis you'll need to generate a `cache_encryption_key`. This can be done either by running `mix keygen` or by using the following snippet:

Expand Down

0 comments on commit 0e8e644

Please sign in to comment.