ets v0.1.1 Ets.Table.New View Source

Provides functionality to create :ets tables. Type of table is specified by picking the appropriate function. Specifying an atom as the first parameter will result in a named table, not specifying will result in an unnamed table. All functions return {:ok, return} | {:error, reason} tuples, and have a bang (ending in !) which returns the raw value or raises on :error. Named versions return the name of the table, unnamed versions return a reference to the table.

Examples

iex> {:ok, ref} = Ets.Table.New.bag()
iex> is_reference(ref)
true

iex> Ets.Table.New.bag(:my_ets_table)
{:ok, :my_ets_table}

Options

All variations take keyword options:

protection: :private, :protected, :public
heir: :none | {heir_pid, heir_data}
keypos: integer
read_concurrency: boolean
write_concurrency: boolean
compressed: boolean

Examples

iex> {:ok, ref} = Ets.Table.New.bag(protection: :private, heir: {self(), :data}, keypos: 5)
iex> is_reference(ref)
true

iex> Ets.Table.New.bag(:my_ets_table, protection: :public, heir: :none, keypos: 2)
{:ok, :my_ets_table}

Link to this section Summary

Functions

Same as bag/0 but raises on :error

Same as bag/1 but raises on :error

Same as bag/2 but raises on :error

Creates a new unnamed :ets table with the type :bag and default options

Creates a new unnamed :ets table with the type :bag and specified options

Creates a new named :ets table with the type :bag and any specified options

Same as duplicate_bag/0 but raises on :error

Same as duplicate_bag/1 but raises on :error

Same as duplicate_bag/2 but raises on :error

Creates a new unnamed :ets table with the type :duplicate_bag and default options

Creates a new unnamed :ets table with the type :duplicate_bag and specified options

Creates a new named :ets table with the type :duplicate_bag and any specified options

Same as ordered_set/0 but raises on :error

Same as ordered_set/1 but raises on :error

Same as ordered_set/2 but raises on :error

Creates a new unnamed :ets table with the type :ordered_set and default options

Creates a new unnamed :ets table with the type :ordered_set and specified options

Creates a new named :ets table with the type :ordered_set and any specified options

Same as set/0 but raises on :error

Same as set/1 but raises on :error

Same as set/2 but raises on :error

Creates a new unnamed :ets table with the type :set and default options

Creates a new unnamed :ets table with the type :set and specified options

Creates a new named :ets table with the type :set and any specified options

Link to this section Types

Link to this type new_named_return() View Source
new_named_return() ::
  {:ok, atom()}
  | {:error, :table_alrady_exists | {:invalid_options, any()} | :unknown_error}
Link to this type new_return() View Source
new_return() ::
  {:ok, Ets.ets_table_reference()}
  | {:error, {:invalid_options, any()} | :unknown_error}
Link to this type option() View Source
option() ::
  {:protection, :private | :protected | :public}
  | {:heir, :none | {pid(), any()}}
  | {:keypos, non_neg_integer()}
  | {:write_concurrency, boolean()}
  | {:read_concurrency, boolean()}
  | {:compressed, boolean()}
Link to this type options() View Source
options() :: [option()]
Link to this type protection_types() View Source
protection_types() :: :public | :protected | :private
Link to this type table_types() View Source
table_types() :: :bag | :duplicate_bag | :ordered_set | :set

Link to this section Functions

Same as bag/0 but raises on :error.

Returns reference of newly created table.

Examples

iex> {:ok, ref} = Ets.Table.New.bag()
iex> is_reference(ref)
true

Same as bag/1 but raises on :error.

Returns reference of newly created table.

Same as bag/2 but raises on :error.

Returns reference of newly created table.

Creates a new unnamed :ets table with the type :bag and default options.

Returns :ok/:error tuple. :ok tuple contains table reference

Creates a new unnamed :ets table with the type :bag and specified options.

Returns :ok/:error tuple. :ok tuple contains reference of newly created table.

Examples

iex> {:ok, ref} = Ets.Table.New.bag(protection: :private)
iex> is_reference(ref)
true

Creates a new named :ets table with the type :bag and any specified options.

Returns :ok/:error tuple. :ok tuple contains reference of newly created table

Examples

iex> Ets.Table.New.bag(:my_ets_table)
{:ok, :my_ets_table}

iex> Ets.Table.New.bag(:my_ets_table, protection: :private)
{:ok, :my_ets_table}

iex> Ets.Table.New.bag(:my_ets_table)
{:ok, :my_ets_table}
iex> Ets.Table.New.bag(:my_ets_table)
{:error, :table_already_exists}
Link to this macro catch_table_already_exists(table_name, list) View Source (macro)

Same as duplicate_bag/0 but raises on :error.

Returns reference of newly created table.

Examples

iex> {:ok, ref} = Ets.Table.New.duplicate_bag()
iex> is_reference(ref)
true
Link to this function duplicate_bag!(opts) View Source
duplicate_bag!(options()) :: Ets.ets_table_reference()

Same as duplicate_bag/1 but raises on :error.

Returns reference of newly created table.

Link to this function duplicate_bag!(name, opts \\ []) View Source
duplicate_bag!(Ets.table_name(), options()) :: Ets.table_name()

Same as duplicate_bag/2 but raises on :error.

Returns reference of newly created table.

Link to this function duplicate_bag() View Source
duplicate_bag() :: new_return()

Creates a new unnamed :ets table with the type :duplicate_bag and default options.

Returns :ok/:error tuple. :ok tuple contains table reference

Link to this function duplicate_bag(opts) View Source
duplicate_bag(options()) :: new_return()

Creates a new unnamed :ets table with the type :duplicate_bag and specified options.

Returns :ok/:error tuple. :ok tuple contains reference of newly created table.

Examples

iex> {:ok, ref} = Ets.Table.New.duplicate_bag(protection: :private)
iex> is_reference(ref)
true
Link to this function duplicate_bag(name, opts \\ []) View Source
duplicate_bag(Ets.table_name(), options()) :: new_named_return()

Creates a new named :ets table with the type :duplicate_bag and any specified options.

Returns :ok/:error tuple. :ok tuple contains reference of newly created table

Examples

iex> Ets.Table.New.duplicate_bag(:my_ets_table)
{:ok, :my_ets_table}

iex> Ets.Table.New.duplicate_bag(:my_ets_table, protection: :private)
{:ok, :my_ets_table}

iex> Ets.Table.New.duplicate_bag(:my_ets_table)
{:ok, :my_ets_table}
iex> Ets.Table.New.duplicate_bag(:my_ets_table)
{:error, :table_already_exists}

Same as ordered_set/0 but raises on :error.

Returns reference of newly created table.

Examples

iex> {:ok, ref} = Ets.Table.New.ordered_set()
iex> is_reference(ref)
true

Same as ordered_set/1 but raises on :error.

Returns reference of newly created table.

Link to this function ordered_set!(name, opts \\ []) View Source
ordered_set!(Ets.table_name(), options()) :: Ets.table_name()

Same as ordered_set/2 but raises on :error.

Returns reference of newly created table.

Link to this function ordered_set() View Source
ordered_set() :: new_return()

Creates a new unnamed :ets table with the type :ordered_set and default options.

Returns :ok/:error tuple. :ok tuple contains table reference

Link to this function ordered_set(opts) View Source
ordered_set(options()) :: new_return()

Creates a new unnamed :ets table with the type :ordered_set and specified options.

Returns :ok/:error tuple. :ok tuple contains reference of newly created table.

Examples

iex> {:ok, ref} = Ets.Table.New.ordered_set(protection: :private)
iex> is_reference(ref)
true
Link to this function ordered_set(name, opts \\ []) View Source
ordered_set(Ets.table_name(), options()) :: new_named_return()

Creates a new named :ets table with the type :ordered_set and any specified options.

Returns :ok/:error tuple. :ok tuple contains reference of newly created table

Examples

iex> Ets.Table.New.ordered_set(:my_ets_table)
{:ok, :my_ets_table}

iex> Ets.Table.New.ordered_set(:my_ets_table, protection: :private)
{:ok, :my_ets_table}

iex> Ets.Table.New.ordered_set(:my_ets_table)
{:ok, :my_ets_table}
iex> Ets.Table.New.ordered_set(:my_ets_table)
{:error, :table_already_exists}

Same as set/0 but raises on :error.

Returns reference of newly created table.

Examples

iex> {:ok, ref} = Ets.Table.New.set()
iex> is_reference(ref)
true

Same as set/1 but raises on :error.

Returns reference of newly created table.

Same as set/2 but raises on :error.

Returns reference of newly created table.

Creates a new unnamed :ets table with the type :set and default options.

Returns :ok/:error tuple. :ok tuple contains table reference

Creates a new unnamed :ets table with the type :set and specified options.

Returns :ok/:error tuple. :ok tuple contains reference of newly created table.

Examples

iex> {:ok, ref} = Ets.Table.New.set(protection: :private)
iex> is_reference(ref)
true

Creates a new named :ets table with the type :set and any specified options.

Returns :ok/:error tuple. :ok tuple contains reference of newly created table

Examples

iex> Ets.Table.New.set(:my_ets_table)
{:ok, :my_ets_table}

iex> Ets.Table.New.set(:my_ets_table, protection: :private)
{:ok, :my_ets_table}

iex> Ets.Table.New.set(:my_ets_table)
{:ok, :my_ets_table}
iex> Ets.Table.New.set(:my_ets_table)
{:error, :table_already_exists}
Link to this function table_named(name, type, opts) View Source