Creating an ETS Table
You create ETS tables by calling ets:new
. The process
that creates the table is called the owner of the
table. When you create the table, it has a set of options that
cannot be changed. If the owner process dies, space for the
table is automatically deallocated. You can delete the table
by calling ets:delete
.
The arguments to ets:new
are as follows:
-spec ets:new(Name, [Opt]) -> TableId
-
Name
is an atom.[Opt]
is a list of options, taken from the following:set | ordered_set | bag | duplicate_bag
-
This creates an ETS table of the given type (we talked about these earlier).
private
-
This creates a private table. Only the owner process can read and write this table.
public
-
This creates a public table. Any process that knows the ...
Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.