AshAuthentication.Oauth2Server.CIMD.Cache (ash_authentication_oauth2_server v0.3.0)

Copy Markdown View Source

ETS cache for fetched Client ID Metadata Documents.

Started by AshAuthentication.Oauth2Server.Supervisor. The cache is a pure optimization — every read/write degrades to a no-op when the supervisor (and therefore the table) isn't running, so CIMD keeps working without it, just with a fetch per authorize request.

Entries are keyed by the exact client_id URL and honour the TTL the fetcher derived from the document's HTTP cache headers. The table is bounded (@max_entries) so a flood of one-off client URLs can't grow it without limit, and expired entries are swept periodically.

Summary

Functions

Returns a specification to start this module under a supervisor.

Look up a cached document. Returns {:ok, document} or :miss.

Cache a document for ttl seconds. A ttl of 0 (or the table being absent or full) is a no-op.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get(url)

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

Look up a cached document. Returns {:ok, document} or :miss.

put(url, document, ttl)

@spec put(String.t(), map(), non_neg_integer()) :: :ok

Cache a document for ttl seconds. A ttl of 0 (or the table being absent or full) is a no-op.