# `LLMProxy.Cache`
[🔗](https://github.com/elixir-vibe/llm_proxy/blob/v0.3.1/lib/llm_proxy/cache.ex#L1)

Behaviour for deterministic response cache adapters.

Configure one adapter with:

    config :llm_proxy, cache: MyApp.LLMCache

The adapter receives a deterministic cache key and context map. It stores and
returns `%LLMProxy.Response{}` values; external adapters can serialize the
response if needed. Cache access requires an API key with explicit content
capture because responses include model output and request context.

# `context`

```elixir
@type context() :: %{
  optional(:actor) =&gt; LLMProxy.Actor.t(),
  optional(:api_key) =&gt; map(),
  optional(:route) =&gt; atom(),
  optional(:model) =&gt; String.t(),
  optional(:provider) =&gt; module(),
  optional(:provider_name) =&gt; String.t() | nil,
  optional(:trace_id) =&gt; String.t(),
  optional(:cache_key) =&gt; String.t(),
  optional(:metadata) =&gt; map()
}
```

# `get`

```elixir
@callback get(String.t(), context()) ::
  {:hit, LLMProxy.Response.t()} | :miss | {:error, term()}
```

# `put`
*optional* 

```elixir
@callback put(String.t(), LLMProxy.Response.t(), context()) :: :ok | {:error, term()}
```

---

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