View Source Nebulex.Adapter behaviour (Nebulex v2.3.1)

Specifies the minimal API required from adapters.

Link to this section Summary

Types

The metadata returned by the adapter init/1.

Metadata type

t()

Adapter

Callbacks

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

Initializes the adapter supervision tree by returning the children.

Functions

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

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

Link to this section Types

Specs

adapter_meta() :: metadata()

The metadata returned by the adapter 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 init/1

Specs

metadata() :: %{optional(atom()) => term()}

Metadata type

Specs

t() :: module()

Adapter

Link to this section Callbacks

Specs

__before_compile__(term(), env :: Macro.Env.t()) :: Macro.t()

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

Specs

init(config :: Keyword.t()) :: {:ok, :supervisor.child_spec(), adapter_meta()}

Initializes the adapter supervision tree by returning the children.

Link to this section Functions

Link to this macro

defspan(fun, opts \\ [], list)

View Source (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.

Link to this function

with_meta(name_or_pid, fun)

View Source

Specs

with_meta(atom() | pid(), (module(), adapter_meta() -> term())) :: term()

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

It expects a name or a PID representing the cache.