Module ets

A limited implementation of the Erlang/OTP ets module.

Data Types

access_type()


access_type() = private | protected | public

option()


option() = table_type() | {keypos, non_neg_integer()} | access_type()

options()


options() = [option()]

table()

abstract datatype: table()

table_type()


table_type() = set

Function Index

delete/2Delete an entry from an ets table.
insert/2Insert an entry into an ets table.
lookup/2Look up an entry in an ets table.
lookup_element/3Look up an element from an entry in an ets table.
new/2Create a new ets table.
update_counter/3Updates a counter value at Key in the table.
update_counter/4Updates a counter value at Key in the table.

Function Details

delete/2


delete(Table::table(), Key::term()) -> true

Table: a reference to the ets table
Key: the key used to lookup one or more entries to delete

returns: true; otherwise, an error is raised if arguments are bad

Delete an entry from an ets table.

insert/2


insert(Table::table(), Entry::tuple() | [tuple()]) -> true

Table: a reference to the ets table
Entry: the entry to insert

returns: true; otherwise, an error is raised if arguments are bad

Insert an entry into an ets table.

lookup/2


lookup(Table::table(), Key::term()) -> [tuple()]

Table: a reference to the ets table
Key: the key used to lookup one or more entries

returns: the entry in a set, or a list of entries, if the table permits

Look up an entry in an ets table.

lookup_element/3


lookup_element(Table::table(), Key::term(), Pos::pos_integer()) -> term()

Table: a reference to the ets table
Key: the key used to lookup one or more entries
Pos: index of the element to retrieve (1-based)

returns: the Pos:nth element of entry in a set, or a list of entries, if the table permits

Look up an element from an entry in an ets table.

new/2


new(Name::atom(), Options::options()) -> table()

Name: the ets table name
Options: the options used to create the table

returns: A new ets table

Create a new ets table.

update_counter/3


update_counter(Table::table(), Key::term(), Params::integer() | {pos_integer(), integer()} | {pos_integer(), integer(), integer(), integer()}) -> integer()

Table: a reference to the ets table
Key: the key used to look up the entry expecting to contain a tuple of integers or a single integer
Params: the increment value or a tuple {Pos, Increment} or {Pos, Increment, Treshold, SetValue}, where Pos is an integer (1-based index) specifying the position in the tuple to increment. Value is clamped to SetValue if it exceeds Threshold after update.

returns: the updated element’s value after performing the increment, or the default value if applicable

Updates a counter value at Key in the table. If Params is a single integer, it increments the direct integer value at Key or the first integer in a tuple. If Params is a tuple {Pos, Increment}, it increments the integer at the specified position Pos in the tuple stored at Key.

update_counter/4


update_counter(Table::table(), Key::term(), Params::integer() | {pos_integer(), integer()} | {pos_integer(), integer(), integer(), integer()}, Default::integer()) -> integer()

Table: a reference to the ets table
Key: the key used to look up the entry expecting to contain a tuple of integers or a single integer
Params: the increment value or a tuple {Pos, Increment} or {Pos, Increment, Treshold, SetValue}, where Pos is an integer (1-based index) specifying the position in the tuple to increment. If after incrementation value exceeds the Treshold, it is set to SetValue.
Default: the default value used if the entry at Key doesn’t exist or doesn’t contain a valid tuple with a sufficient size or integer at Pos

returns: the updated element’s value after performing the increment, or the default value if applicable

Updates a counter value at Key in the table. If Params is a single integer, it increments the direct integer value at Key or the first integer in a tuple. If Params is a tuple {Pos, Increment}, it increments the integer at the specified position Pos in the tuple stored at Key. If the needed element does not exist, uses Default value as a fallback.