# `AttestoPhoenix.ClientIdMetadata.Cache.ETS`
[🔗](https://github.com/XukuLLC/attesto_phoenix/blob/v0.19.0/lib/attesto_phoenix/store/ets_client_id_metadata_cache.ex#L1)

Single-node ETS `AttestoPhoenix.ClientIdMetadata.Cache` - CIMD
(`draft-ietf-oauth-client-id-metadata-document-01`, IETF OAuth WG).

Caches a validated Client ID Metadata Document in per-node memory keyed by its
`client_id` URL. A per-node cache is correct for CIMD - a miss simply
re-fetches and re-validates - so this is the single-node opt-out from the
default `AttestoPhoenix.ClientIdMetadata.Cache.Ecto`, which a clustered
deployment prefers for cross-node coherence and to bound outbound fetch
fan-out. Select it by configuring `:cache` under `AttestoPhoenix.Config`'s
`:client_id_metadata` key.

Only a validated document is ever stored (the caller stores after
`Attesto.ClientIdMetadata.validate_document/2` succeeds), and freshness is
re-checked on read against the stored `expires_at`, so an expired entry is a
`:miss` and is evicted in passing - never served stale.

# `get`

```elixir
@spec get(String.t()) :: {:ok, map()} | :miss
```

Resolves a live cached document for a CIMD `client_id` URL.

Returns `{:ok, metadata}` for a present, unexpired entry, or `:miss` when it
is absent or expired. An expired entry is deleted in passing (it can never be
honored again), so freshness is enforced on read, not by sweeping.

# `put`

```elixir
@spec put(String.t(), map(), DateTime.t()) :: :ok
```

Caches validated `metadata` for a CIMD `client_id` URL until `expires_at`.

A re-fetched document supersedes a stale one, so this overwrites any existing
entry for the same `url` (`:ets.insert/2` replaces a set row), keyed by URL.

---

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