fdb v5.1.7-2 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

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 FDB.Transaction.Coder.t/0 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 type t() View Source
t() :: %FDB.Database{coder: term(), resource: term()}

Link to this section Functions

Link to this function create(cluster, coder \\ Transaction.Coder.new()) View Source

Creates a new database.

Link to this function create_q(cluster, coder \\ Transaction.Coder.new()) View Source

Async version of create/2

Link to this function get_range(database, key_range, options \\ %{}) View Source
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.

Link to this function set_coder(db, coder) View Source
set_coder(t(), FDB.Transaction.Coder.t()) :: t()

Changes the FDB.Transaction.Coder.t/0 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_coder(db, user_coder)
comments_db = FDB.Database.set_coder(db, comment_coder)
Link to this function set_option(database, option) View Source
set_option(t(), FDB.Option.key()) :: :ok

Refer FDB.Option for the list of options. Any option that starts with database_option_ is allowed.

Link to this function set_option(database, option, value) View Source
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.

Link to this function transact(database, callback) View Source
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