# `Orchid.Repo`
[🔗](https://github.com/SynapticStrings/Orchid/blob/main/lib/orchid/repo.ex#L1)

Behaviour for pluggable key-value storage adapters.

Provides the minimal contract shared by every store used in the Orchid
ecosystem: write a value, read it back.  Domain-specific extensions
(existence checks, deletion, garbage collection, bulk export) are
defined as separate optional behaviours under `Orchid.Repo.*`.

## Store Reference

Every callback receives an opaque `store_ref` as its first argument.
The concrete type is determined by the adapter (an ETS tid, a map of
connection options, a PID, etc.).  Callers obtain the reference from
the adapter's own `init/1` or equivalent.

## Composition with Extension Behaviours

Adapters declare the capabilities they support:

    defmodule MyApp.BlobStore do
      @behaviour Orchid.Repo
      @behaviour Orchid.Repo.ContentAddressable
      # implements get/2, put/3, exists?/2
    end

    defmodule MyApp.MetaStore do
      @behaviour Orchid.Repo
      @behaviour Orchid.Repo.Deletable
      @behaviour Orchid.Repo.GC
      # implements get/2, put/3, delete/2, garbage_collect/2
    end

# `key`
[🔗](https://github.com/SynapticStrings/Orchid/blob/main/lib/orchid/repo.ex#L36)

```elixir
@type key() :: binary()
```

# `store_ref`
[🔗](https://github.com/SynapticStrings/Orchid/blob/main/lib/orchid/repo.ex#L35)

```elixir
@type store_ref() :: term()
```

# `value`
[🔗](https://github.com/SynapticStrings/Orchid/blob/main/lib/orchid/repo.ex#L37)

```elixir
@type value() :: term()
```

# `get`
[🔗](https://github.com/SynapticStrings/Orchid/blob/main/lib/orchid/repo.ex#L47)

```elixir
@callback get(store :: store_ref(), key()) :: {:ok, value()} | :miss
```

Retrieves the value associated with `key`.

Returns `{:ok, value}` on a hit, or `:miss` if no entry exists.

# `put`
[🔗](https://github.com/SynapticStrings/Orchid/blob/main/lib/orchid/repo.ex#L40)

```elixir
@callback put(store :: store_ref(), key(), value()) :: :ok
```

Persists `value` under `key`. Must be idempotent.

# `dispatch_store`
[🔗](https://github.com/SynapticStrings/Orchid/blob/main/lib/orchid/repo.ex#L53)

Resolves a {Module, instance} store configuration tuple and dispatches
the given function call, prepending the instance as the first argument.

---

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