X402.Extensions.PaymentIdentifier.ETSCache (X402 v0.3.3)

Copy Markdown View Source

ETS-backed cache adapter for payment identifier idempotency.

Entries expire after :ttl_ms (default: 1 hour). Expired entries are removed by an internal periodic cleanup loop.

Summary

Types

Server identifier accepted by GenServer.call/3.

Functions

Deletes a payment identifier entry from the cache.

Looks up a payment identifier in the cache.

Stores a payment identifier result in the cache.

Atomically inserts a payment identifier only if it does not already exist.

Starts an ETS-backed idempotency cache process.

Types

server()

@type server() :: GenServer.server()

Server identifier accepted by GenServer.call/3.

Functions

child_spec(init_arg)

(since 0.1.0)
@spec child_spec(keyword()) :: Supervisor.child_spec()

Returns a child specification for X402.Extensions.PaymentIdentifier.ETSCache.

delete(cache, payment_id)

(since 0.1.0)

Deletes a payment identifier entry from the cache.

get(cache, payment_id)

(since 0.1.0)

Looks up a payment identifier in the cache.

put(cache, payment_id, value)

(since 0.1.0)

Stores a payment identifier result in the cache.

put_new(cache, payment_id, value)

(since 0.4.0)
@spec put_new(
  server(),
  X402.Extensions.PaymentIdentifier.Cache.key(),
  X402.Extensions.PaymentIdentifier.Cache.value()
) :: :ok | {:error, :already_exists | :invalid_cache_value}

Atomically inserts a payment identifier only if it does not already exist.

Returns :ok if the entry was inserted, or {:error, :already_exists} if a non-expired entry for payment_id is already present. This is used to prevent concurrent requests from double-settling the same payment proof.

start_link(opts \\ [])

(since 0.1.0)
@spec start_link(keyword()) ::
  GenServer.on_start() | {:error, NimbleOptions.ValidationError.t()}

Starts an ETS-backed idempotency cache process.

Options