scarab Build StatusHex.pmHex.pm

content-addressable file storage for elixir

Installation

Scarab is available in Hex and can be installed as:

  1. Add concerto your list of dependencies in mix.exs:

    def deps do

     [{:scarab, "~> 0.1.0"}]

    end

Usage

Start by defining a repo:

defmodule My.Repo do
  use Scarab, backend: Scarab.Backend.FS,
              config: %{path: ".repo"}
end

Available backends include:

Now we can put and get contents:

{:ok, hash} = My.Repo.put("Hello, world!")

IO.inspect hash
## ":lDpwLQbzRZmu4fjajvn3KWAx1pk"

{:ok, "Hello, world!"} = My.Repo.get(hash)

We can also add namespaced links for easy lookup:

{:ok, hash} = My.Repo.put("Hello, links!")
:ok = My.Repo.link("my-namespace", "my-link", hash)

My.Repo.resolve("my-namespace", "my-link") |> IO.inspect
## {:ok, "Hello, links!"}

My.Repo.unlink("my-namespace", "my-link")

My.Repo.resolve("my-namespace", "my-link") |> IO.inspect
## {:error, :enoent}