AshOnetime.Cache behaviour (ash_onetime v0.5.0)

Copy Markdown View Source

Optional cache behaviour for completed idempotency responses.

Cache data is never admission authority. PostgreSQL is consulted first on every request, and a hit is usable only after its claim id, fingerprint, codec, digest, size, and payload digest match the authoritative claim.

Summary

Callbacks

delete(cache_key)

@callback delete(cache_key :: binary()) :: :ok | {:error, term()}

get(cache_key)

@callback get(cache_key :: binary()) ::
  :miss | {:ok, AshOnetime.Cache.Entry.t()} | {:error, term()}

put(cache_key, t, ttl_seconds)

@callback put(
  cache_key :: binary(),
  AshOnetime.Cache.Entry.t(),
  ttl_seconds :: pos_integer()
) ::
  :ok | {:error, term()}