View Source ETS (ets v0.9.0)
ETS, an Elixir wrapper for Erlang's :ets
module.
See ETS.Set
for information on creating and managing Sets, and ETS.Bag
for information on creating and managing Bags.
See ETS.KeyValueSet
for an abstraction which provides standard key/value interaction with Sets.
what-type-of-ets-table-should-i-use
What type of ETS
table should I use?
set
Set
If you need your key column to be unique, then you should use a Set. If you just want a simple key/value store,
then use an ETS.KeyValueSet
, but if you want to store full tuple records, use an ETS.Set
. If you want your
records ordered by key value, which adds some performance overhead on insertion, set ordered: true
when creating the Set (defaults to false).
bag
Bag
If you do not need your key column to be unique, then you should use an ETS.Bag
, and if you want to prevent exact duplicate
records from being inserted, which adds some performance overhead on insertion, set duplicate: false when creating the Bag
(defaults to true).
Link to this section Summary
Link to this section Types
Specs
comp_match_spec() :: :ets.comp_match_spec()
Specs
continuation() :: end_of_table() | {table_reference(), integer(), integer(), comp_match_spec(), list(), integer()} | {table_reference(), any(), any(), integer(), comp_match_spec(), list(), integer(), integer()}
Specs
end_of_table() :: :"$end_of_table"
Specs
match_pattern() :: :ets.match_pattern()
Specs
match_spec() :: :ets.match_spec()
Specs
table_identifier() :: table_name() | table_reference()
Specs
table_name() :: atom()
Specs
table_reference() :: :ets.tid()
Link to this section Functions
Specs
all() :: {:ok, [table_identifier()]} | {:error, any()}
Returns list of current :ets tables, each wrapped as either ETS.Set
or ETS.Bag
.
NOTE: ETS.Bag
is not yet implemented. This list returns only :set and :ordered_set tables, both wrapped as ETS.Set
.
examples
Examples
iex> {:ok, all} = ETS.all()
iex> x = length(all)
iex> ETS.Set.new!()
iex> {:ok, all} = ETS.all()
iex> length(all) == x + 1
true
Specs
all!() :: [table_identifier()]
Same as all/1 but unwraps or raises on :error.