# `IdempotencyPlug.EctoStore`
[🔗](https://github.com/danschultzer/idempotency_plug/blob/v0.2.2/lib/idempotency_plug/store/ecto_store.ex#L2)

Module that defines an Ecto store.

A migration file should be generated with
`mix idempotency_plug.ecto.gen.migration`.

## Performance considerations

For most workloads no tuning is needed — POST/PATCH traffic is rarely
high enough for the table to become a bottleneck, and there are likely
several downstream writes happening in the same request.

However, in high-write database workloads, WAL pressure may become a
bottleneck. With Postgres this can be mitigated by setting the table to
UNLOGGED to skip WAL entirely:

    ALTER TABLE idempotency_plug_requests SET UNLOGGED

Unclean shutdowns are rare, but UNLOGGED is still only appropriate when
losing the idempotency cache during recovery is acceptable. Not
recommended for payments or other critical cases.

## Examples

    defmodule MyApp.Application do
      # ..

      def start(_type, _args) do
        children = [
          {IdempotencyPlug.RequestTracker, [
            store: {IdempotencyPlug.EctoStore, repo: MyApp.Repo}]}
          # ...
        ]

        Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
      end
    end

---

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