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
Summary
Functions
Resolves a {Module, instance} store configuration tuple and dispatches the given function call, prepending the instance as the first argument.
Types
Callbacks
Retrieves the value associated with key.
Returns {:ok, value} on a hit, or :miss if no entry exists.
Persists value under key. Must be idempotent.