CubDB.start_link
start_link
, go back to CubDB module for more information.
Specs
start_link( String.t() | [option() | {:data_dir, String.t()} | GenServer.option()] ) :: GenServer.on_start()
Starts the CubDB
database process linked to the current process.
The argument is a keyword list of options:
data_dir
: the directory path where the database files will be stored. This option is required. If the directory does not exist, it will be created. Only oneCubDB
instance can run per directory, so if you run several databases, they should each use their own separate data directory.auto_compact
: whether to perform compaction automatically. It defaults totrue
. Seeset_auto_compact/2
for the possible valuesauto_file_sync
: whether to force flush the disk buffer on each write. It defaults totrue
. If set tofalse
, write performance is faster, but durability of writes is not strictly guaranteed. Seeset_auto_file_sync/2
for details.
GenServer
options like name
and timeout
can also be given, and are
forwarded to GenServer.start_link/3
as the third argument.
If only the data_dir
is specified, it is possible to pass it as a single
string argument.
Examples
# Passing only the data dir
{:ok, db} = CubDB.start_link("some/data/dir")
# Passing data dir and other options
{:ok, db} = CubDB.start_link(data_dir: "some/data/dir", auto_compact: true, name: :db)