# `Nebulex.Adapter`
[🔗](https://github.com/elixir-nebulex/nebulex/blob/v2.6.6/lib/nebulex/adapter.ex#L1)

Specifies the minimal API required from adapters.

# `adapter_meta`

```elixir
@type adapter_meta() :: metadata()
```

The metadata returned by the adapter `c:init/1`.

It must be a map and Nebulex itself will always inject two keys into
the meta:

  * `:cache` - The cache module.
  * `:pid` - The PID returned by the child spec returned in `c:init/1`

# `metadata`

```elixir
@type metadata() :: %{optional(atom()) =&gt; term()}
```

Metadata type

# `t`

```elixir
@type t() :: module()
```

Adapter

# `__before_compile__`

```elixir
@macrocallback __before_compile__(env :: Macro.Env.t()) :: Macro.t()
```

The callback invoked in case the adapter needs to inject code.

# `init`

```elixir
@callback init(config :: Keyword.t()) :: {:ok, :supervisor.child_spec(), adapter_meta()}
```

Initializes the adapter supervision tree by returning the children.

# `defspan`
*macro* 

Helper macro for the adapters so they can add the logic for emitting the
recommended Telemetry events.

See the built-in adapters for more information on how to use this macro.

# `with_meta`

```elixir
@spec with_meta(atom() | pid(), (module(), adapter_meta() -&gt; term())) :: term()
```

Executes the function `fun` passing as parameters the adapter and metadata
(from the `c:init/1` callback) associated with the given cache `name_or_pid`.

It expects a name or a PID representing the cache.

---

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