# `Attesto.PreAuthorizedCodeStore.ETS`
[🔗](https://github.com/XukuLLC/attesto/blob/v2.0.1/lib/attesto/pre_authorized_code_store/ets.ex#L1)

Single-node ETS implementation of `Attesto.PreAuthorizedCodeStore`.

Pre-authorized codes live in a `:protected` ETS table owned by a `GenServer`
that sweeps expired rows on a fixed interval. `put/1` and `take/1` are
routed through the owner process (`GenServer.call/2`) so every write happens
there; `take/1`'s underlying `:ets.take/2` still fetches and deletes a row
in one atomic step, so the single-use guarantee holds against concurrent
redemptions on a node. This is a per-node store: a multi-node deployment
MUST back `Attesto.PreAuthorizedCodeStore` with a shared store so a code
issued on one node can be redeemed once on another.

## Start options

  * `:sweep_interval_ms` (default `30_000`) - how often expired rows are
    bulk-deleted. Correctness does not depend on sweeping;
    `Attesto.PreAuthorizedCode` re-checks expiry after `take/1`.

## Wiring

    children = [Attesto.PreAuthorizedCodeStore.ETS]

then pass the module as the store:

    Attesto.PreAuthorizedCode.issue(Attesto.PreAuthorizedCodeStore.ETS, attrs)

# `reset`

```elixir
@spec reset() :: :ok
```

Clear every entry. Test-facing.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

---

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