sled v0.1.0-alpha.2 Sled View Source

An Elixir binding for sled, the champagne of beta embedded databases.

A basic example:

iex> db = Sled.open("test_db")
iex> Sled.insert(db, "hello", "world")
iex> Sled.get(db, "hello")
"world"

Link to this section Summary

Types

t()

A reference to a sled db.

A reference to a sled tree. Passing a t/0 refers to the "default" tree for the db, while a Sled.Tree.t/0 references a "tenant" tree.

Functions

Retrieve the value for key from db.

Insert value into db for key.

Open the db with options, by default creating it if it doesn't exist.

Open the sled tenant tree in db named name, creating it if it doesn't exist.

Delete the value for key from db.

Link to this section Types

Specs

t()

A reference to a sled db.

Specs

tree_ref() :: t() | Sled.Tree.t()

A reference to a sled tree. Passing a t/0 refers to the "default" tree for the db, while a Sled.Tree.t/0 references a "tenant" tree.

Link to this section Functions

Specs

get(tree_ref(), binary()) :: binary() | nil | no_return()

Retrieve the value for key from db.

Returns nil if there is no value associated with the key.

Specs

insert(tree_ref(), binary(), binary()) :: binary() | nil | no_return()

Insert value into db for key.

Returns nil if there was no previous value associated with the key.

Specs

open(Path.t() | keyword() | Sled.Config.Options.t()) :: t() | no_return()

Open the db with options, by default creating it if it doesn't exist.

If options is a path, opens the db at the path with default options, creating it if it doesn't exist:

iex> Sled.open("test_default_db")

If options is a keyword or Sled.Config.Options struct, then this function is the same as calling Sled.Config.new/1 and passing the result to Sled.Config.open/1.

Specs

open_tree(t(), String.t()) :: Sled.Tree.t() | no_return()

Open the sled tenant tree in db named name, creating it if it doesn't exist.

Specs

remove(tree_ref(), binary()) :: binary() | nil | no_return()

Delete the value for key from db.

Returns nil if there is no value associated with the key.