An Erlang library that wraps the FoundationDB C API with a NIF.
We also provide a conforming implementation of the Tuple and Directory layers.
This project originated as apache/couchdb-erlfdb. This fork was created in early 2024 to continue development.
Refer to FoundationDB's Getting Started on Linux or Getting Started on macOS.
Install the foundationdb-clients package to run erlfdb as a client to an existing FoundationDB database.
Install the foundationdb-server package for running a test fdbserver on your local device. This package is required to run the unit tests.
Add erlfdb as a dependency in your Erlang project's rebar.config:
% rebar.config
{deps, [
{erlfdb, "1.0.0"}
]}.Add erlfdb as a dependency in your Elixir project's mix.exs:
# mix.exs
defp deps do
[
{:erlfdb, "~> 1.0"}
]
endA simple example showing how to open a database and read and write keys.
See the erlfdb Documentation for more.
1> Db = erlfdb:open(<<"/usr/local/etc/foundationdb/fdb.cluster">>).
{erlfdb_database,#Ref<0.2859661758.3941466120.85406>}
2> ok = erlfdb:set(Db, <<"foo">>, <<"bar">>).
ok
3> erlfdb:get(Db, <<"foo">>).
<<"bar">>
4> erlfdb:get(Db, <<"bar">>).
not_foundiex> db = :erlfdb.open("/usr/local/etc/foundationdb/fdb.cluster")
{:erlfdb_database, #Reference<0.2859661758.3941466120.85406>}
iex> :ok = :erlfdb.set(db, "foo", "bar")
:ok
iex> :erlfdb.get(db, "foo")
"bar"
iex> :erlfdb.get(db, "bar")
:not_foundFoundationDB has a custom binding tester that can be used to test whether changes have broken compatibility. The GitHub Action runs the Binding Tester against the most recent supported version of FoundationDB.
$ rebar3 compile
# rebar3 eunit
When you execute a rebar command, erlfdb attempts to detect the FDB API version
via fdbcli. If it cannot be determined, the rebar command is aborted.
To disable the abort, use ERLFDB_ASSERT_API_VERSION=0. For example, you can safely use
this for the fmt command, which does not do a compile action.
ERLFDB_ASSERT_API_VERSION=0 rebar3 fmt