# `Tezex.Rpc.EntrypointCache`
[🔗](https://github.com/objkt-com/tezex/blob/v6.0.0/lib/rpc/entrypoint_cache.ex#L1)

Cache for the results of `Tezex.Rpc.entrypoints/2` and `Tezex.Rpc.entrypoint/3`.

The process only owns a named public ETS table. Callers read and write the
table directly, so lookups never go through the process.

Keys:

  * `{endpoint, chain_id, address}` for the entrypoint list of a contract
  * `{endpoint, chain_id, address, name}` for the type of one entrypoint

The endpoint is part of the key so that two networks never share entries.
A contract's code can't change once it is deployed, so entries never expire.
Only `{:ok, _}` results are stored. Once the table uses 32 MiB, storing one
more entry empties it first.

# `key`

```elixir
@type key() ::
  {endpoint :: binary(), chain_id :: binary(), address :: binary()}
  | {endpoint :: binary(), chain_id :: binary(), address :: binary(),
     name :: binary()}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `clear`

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

Remove every entry.

# `fetch`

```elixir
@spec fetch(key(), (-&gt; {:ok, value} | {:error, reason})) ::
  {:ok, value} | {:error, reason}
when value: term(), reason: term()
```

Return the cached value for `key` as `{:ok, value}`. On a miss, call `fun`,
store its result if it is `{:ok, value}`, and return it.

# `lookup`

```elixir
@spec lookup(key()) :: {:ok, term()} | :error
```

Return `{:ok, value}` if `key` is cached, `:error` otherwise.

# `put`

```elixir
@spec put(key(), term()) :: :ok
```

Store `value` under `key`.

---

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