fdb v5.1.7-7 FDB.Database View Source
This module provides functions to create and configure database and functions to do transactions on database.
Link to this section Summary
Functions
Creates a new database
Async version of create/2
Refer FDB.Transaction.get_range/3
. The only difference is the
consistency guarantee. This function uses multiple transactions to
fetch the data. This is advantageous if you want to fetch large
amount of data and are ok with the fact that the data might change
when doing the iteration
Changes the defaults options associated with the database
Refer FDB.Option
for the list of options. Any option that starts with database_option_
is allowed
Refer FDB.Option
for the list of options. Any option that starts with database_option_
is allowed
The given callback
will be called with a
FDB.Transaction.t/0
Link to this section Types
Link to this section Functions
create(FDB.Cluster.t(), map()) :: t()
Creates a new database.
create_q(FDB.Cluster.t(), map()) :: FDB.Future.t()
Async version of create/2
get_range(t(), FDB.KeySelectorRange.t(), map()) :: Enumerable.t()
Refer FDB.Transaction.get_range/3
. The only difference is the
consistency guarantee. This function uses multiple transactions to
fetch the data. This is advantageous if you want to fetch large
amount of data and are ok with the fact that the data might change
when doing the iteration.
Changes the defaults options associated with the database.
This doesn’t create a new database resource, the same database resource is shared. This is the recommended way if one needs to use multiple coders.
db = FDB.Database.create(cluster)
user_db = FDB.Database.set_defaults(db, %{coder: user_coder})
comments_db = FDB.Database.set_defaults(db, %{coder: comment_coder})
set_option(t(), FDB.Option.key()) :: :ok
Refer FDB.Option
for the list of options. Any option that starts with database_option_
is allowed.
set_option(t(), FDB.Option.key(), FDB.Option.value()) :: :ok
Refer FDB.Option
for the list of options. Any option that starts with database_option_
is allowed.
transact(t(), (FDB.Transaction.t() -> any())) :: any()
The given callback
will be called with a
FDB.Transaction.t/0
.
The transaction is automatically committed after the callback returns. The value returned by the callback is retuned. In case any exception is raised inside the callback or in the commit function call, the transaction will be retried if the error is retriable. It also implements an exponential backoff strategy to avoid swamping the database cluster with excessive retries when there is a high level of conflict between transactions.
Avoid doing any IO or any action that will cause side effect inside
the callback
, as the callback
might get called multiple times in
case of errors.
Various options like
FDB.Option.transaction_option_max_retry_delay/0
,
FDB.Option.transaction_option_timeout/0
,
FDB.Option.transaction_option_retry_limit/0
etc which control the
retry behaviour can be configured using
FDB.Transaction.set_option/3