View Source Hologram.Commons.ETS (hologram v0.2.0)

Summary

Functions

Creates a named, public ETS table.

Creates an unnamed, public ETS table.

Deletes the ETS table if it exists.

Deletes a key-value pair from the ETS table.

Deletes the ETS table if it exists or raises ArgumentError otherwise.

Returns the value stored in the ETS table under the given key. If the key doesn't exist the :error :atom is returned.

Returns the value stored in the ETS table under the given key. If the key doesn't exist a KeyError is raised.

Returns all items stored in the ETS table.

Puts multiple items into the ETS table.

Puts an item into the ETS table.

Removes all items from the ETS table.

Determines whether the given ETS table exists.

Types

tid()

@type tid() :: :ets.tid() | atom()

Functions

create_named_table(table_name)

@spec create_named_table(atom()) :: tid()

Creates a named, public ETS table.

create_unnamed_table()

@spec create_unnamed_table() :: tid()

Creates an unnamed, public ETS table.

delete(table_name_or_ref)

@spec delete(tid()) :: boolean()

Deletes the ETS table if it exists.

delete(table_name_or_ref, key)

@spec delete(tid(), any()) :: true

Deletes a key-value pair from the ETS table.

delete!(table_name_or_ref)

@spec delete!(tid()) :: true

Deletes the ETS table if it exists or raises ArgumentError otherwise.

get(table_name_or_ref, key)

@spec get(tid(), any()) :: {:ok, term()} | :error

Returns the value stored in the ETS table under the given key. If the key doesn't exist the :error :atom is returned.

get!(table_name_or_ref, key)

@spec get!(tid(), any()) :: term()

Returns the value stored in the ETS table under the given key. If the key doesn't exist a KeyError is raised.

get_all(table_name_or_ref)

@spec get_all(tid()) :: map()

Returns all items stored in the ETS table.

put(table_name_or_ref, items)

@spec put(tid(), [{any(), any()}]) :: true

Puts multiple items into the ETS table.

put(table_name_or_ref, key, value)

@spec put(tid(), any(), any()) :: true

Puts an item into the ETS table.

reset(table_name_or_ref)

@spec reset(tid()) :: true

Removes all items from the ETS table.

table_exists?(table_ref_or_name)

@spec table_exists?(tid()) :: boolean()

Determines whether the given ETS table exists.