# `MishkaPay.Helpers.TokenCache`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/lib/mishka_pay/__helpers/token_cache.ex#L5)

Access tokens a provider gets for a site's keys (PayPal's OAuth token), kept until shortly
before they expire so each call does not ask for a new one. An ETS table read and written by the
callers themselves; this process only owns it, so no call ever waits on it.

Two callers that find no token at the same time both ask the provider and both keep theirs:
each token is valid, and the next caller reads one of them.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `drop`

```elixir
@spec drop(term()) :: true
```

Forgets the token under `key`, such as one the provider no longer takes.

# `get`

```elixir
@spec get(term(), (-&gt; {:ok, String.t(), pos_integer()} | {:error, term()})) ::
  {:ok, String.t()} | {:error, term()}
```

The token kept under `key`, or a new one from `fetch` (`{:ok, token, expires_in_seconds}`),
kept for next time. An error from `fetch` is answered as it is and nothing is kept.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
