AttestoPhoenix.ClientIdMetadata.Cache.ETS (AttestoPhoenix v0.9.3)

Copy Markdown View Source

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.

Summary

Functions

Resolves a live cached document for a CIMD client_id URL.

Caches validated metadata for a CIMD client_id URL until expires_at.

Functions

get(url)

@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(url, metadata, expires_at)

@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.