Ets Cheat Sheet

From WikiOD

Here is the cheatsheat of Ets and basic guide on how to use Ets

ETS[edit | edit source]

Usage[edit | edit source]

iex> table =, [])
iex> :ets.insert(table, {:fruit, "Apple"})
iex> :ets.lookup(table, :fruit)
     [{:fruit, "Apple"}]
iex> :ets.delete(table)
iex> :ets.delete_all_objects(table)

Flags[edit | edit source]

iex> table =, [:set, :protected])

{: .-setup}

:set | no duplicate keys (or: :ordered_set, :bag, :duplicate_bag) |
:protected | only this process can use it (or: :public, :private) |

Ordered sets[edit | edit source]

:ets.last(table), key)
:ets.prev(table, key)

References[edit | edit source]

{: .-one-column}