Aerospike.Repo (Aerospike Driver v0.3.1)

Copy Markdown View Source

Generates an application-owned facade for one supervised Aerospike cluster.

use Aerospike.Repo binds a Repo module to one cluster name and exposes current Aerospike facade functions without requiring callers to pass that name on every operation.

Define a Repo in your application:

defmodule MyApp.Repo do
  use Aerospike.Repo, otp_app: :my_app
end

Then configure and supervise it:

config :my_app, MyApp.Repo,
  transport: Aerospike.Transport.Tcp,
  hosts: ["127.0.0.1:3000"],
  namespaces: ["test"],
  pool_size: 2

children = [
  MyApp.Repo
]

The generated module delegates to the canonical Aerospike API with conn/0 injected as the cluster name:

key = MyApp.Repo.key("test", "users", "user:1")
{:ok, _metadata} = MyApp.Repo.put(key, %{"name" => "Ada"})
{:ok, record} = MyApp.Repo.get(key)

A Repo is a thin module facade over one cluster. It does not perform schema mapping, changeset validation, query translation, or object reflection.

Summary

Types

Option accepted by use Aerospike.Repo.

Options accepted by use Aerospike.Repo.

t()

Application-owned Repo module generated with use Aerospike.Repo.

Types

option()

@type option() :: {:otp_app, atom()} | {:adapter, module()} | {:name, atom()}

Option accepted by use Aerospike.Repo.

opts()

@type opts() :: [option()]

Options accepted by use Aerospike.Repo.

:otp_app is required and names the application environment used by config/0. :adapter defaults to Aerospike and is mainly useful for tests. :name defaults to the generated Repo module and becomes the cluster identity injected into delegated calls.

t()

@type t() :: module()

Application-owned Repo module generated with use Aerospike.Repo.