Malla.Config (malla v0.0.1-rc.1)

Copy Markdown View Source

A simple ETS-based key-value store for node-wide configuration.

This module provides utilities to store and retrieve data in an ETS table. It is useful for managing configuration or state that is global to a node and needs to be accessed from multiple services or processes.

This store is local to each node and is not distributed.

See the Configuration guide for more details.

Summary

Types

A way to separate key spaces.

Functions

Adds a value to a list stored in the store. The value is added only if it is not already present. Operation is serialized.

Deletes a value from the store.

Retrieves a value from the store. Returns default if not found.

Atomically increments or decrements a counter.

Sets a value in the store.

Updates a store key by applying a function to the current value. This operation is serialized.

Types

domain()

@type domain() :: term()

A way to separate key spaces.

Functions

add(domain, key, val)

@spec add(domain(), term(), term()) :: :ok | {:error, term()}

Adds a value to a list stored in the store. The value is added only if it is not already present. Operation is serialized.

del(domain, key)

@spec del(domain(), term()) :: :ok

Deletes a value from the store.

get(domain, key, default \\ nil)

@spec get(domain(), term(), term()) :: value :: term()

Retrieves a value from the store. Returns default if not found.

increment(domain, key, count)

@spec increment(domain(), term(), integer()) :: integer()

Atomically increments or decrements a counter.

You must previously set an initial value.

put(domain, key, val)

@spec put(domain(), term(), term()) :: :ok

Sets a value in the store.

update(domain, key, fun)

@spec update(domain(), term(), (domain() -> term())) :: :ok

Updates a store key by applying a function to the current value. This operation is serialized.