View Source Diamond (Diamond v0.1.0)

Diamond is a read-only in-memory key/value store.

At application startup, initialize your Diamond storage with initialize/1. Then you can call get/1 from any process to fetch the value(s) you need.

Summary

Functions

Deletes the Diamond storage.

Gets the value of a specified key.

Initializes the Diamond storage with an Enumerable of keys and values.

Types

@type key() :: any()
@type value() :: any()

Functions

@spec drop() :: :ok

Deletes the Diamond storage.

This

Warning: After dropping the storage, your app may no longer call get/1 unless Diamond is re-initialized using initialize/1. Otherwise an error will be raised.

@spec get(key()) :: value() | nil

Gets the value of a specified key.

Returns nil if the key does not exist in the Diamond storage.

Raises an error if the Diamond storage is missing (e.g. cleared or not yet initialized)

@spec initialize(map() | Keyword.t() | [{key(), value()}]) :: :ok

Initializes the Diamond storage with an Enumerable of keys and values.

Raises an error if the Diamond storage already exists.

Note: this can take a while with large datasets (50,000+ keys)

Examples

iex> Diamond.initialize(%{key: "value", foo: "bar"})
:ok
iex> Diamond.initialize([key: "value", foo: "bar"])
:ok
iex> Diamond.initialize([{"key", "value"}, {"foo", "bar"})
:ok