ets v0.6.0 Ets.Set.KeyValueSet View Source
The Key Value Set is an extension of Ets.Set which abstracts the concept of tuple records
away, replacing it with the standard concept of key/value. Behind the scenes, the set stores
its records as {key, value}.
Examples
iex> {:ok, kvset} = KeyValueSet.new()
iex> KeyValueSet.put(kvset, :my_key, :my_val)
iex> KeyValueSet.get(kvset, :my_key)
{:ok, :my_val}
Link to this section Summary
Functions
Same as delete/1 but unwraps or raises on error
Same as delete/2 but unwraps or raises on error
Deletes KeyValueSet. See Ets.Set.delete/1
Deletes record with key in KeyValueSet. See Ets.Set.delete/2
Same as delete_all/1 but unwraps or raises on error
Deletes all records in KeyValueSet. See Ets.Set.delete_all/1
Same as first/1 but unwraps or raises on error
Returns first key in KeyValueSet. See Ets.Set.first/1
Same as get/3 but unwraps or raises on error
Returns value for specified key or the provided default (nil if not specified) if no record found
Same as get_table/1 but unwraps or raises on error
Returns underlying :ets table reference. See Ets.Set.get_table/1
Same as has_key/2 but unwraps or raises on error
Determines if specified key exists in KeyValueSet. See Ets.Set.has_key/2
Same as info/2 but unwraps or raises on error
Returns info on set. See Ets.Set.info/2
Same as last/1 but unwraps or raises on error
Returns last key in KeyValueSet. See Ets.Set.last/1
Same as new/1 but unwraps or raises on error
Creates new Key Value Set module with the specified options
Same as next/2 but unwraps or raises on error
Returns next key in KeyValueSet. See Ets.Set.next/2
Same as previous/2 but unwraps or raises on error
Returns previous key in KeyValueSet. See Ets.Set.previous/2
Same as put/3 but unwraps or raises on error
Puts given value into table for given key
Same as put_new/3 but unwraps or raises on error
Same as put/3 but doesn’t put record if the key already exists
Same as to_list/1 but unwraps or raises on error
Returns contents of table as a list. See Ets.Set.to_list/1
Same as wrap_existing/1 but unwraps or raises on error
Wraps an existing :ets :set or :ordered_set in a KeyValueSet struct
Link to this section Types
set_options() :: [Ets.Base.option() | {:ordered, boolean()}]
Link to this section Functions
Same as delete/1 but unwraps or raises on error.
delete!(Ets.Set.KeyValueSet.t(), any()) :: any()
Same as delete/2 but unwraps or raises on error.
delete(Ets.Set.KeyValueSet.t()) :: {:ok, any()} | {:error, any()}
Deletes KeyValueSet. See Ets.Set.delete/1.
delete(Ets.Set.KeyValueSet.t(), any()) :: {:ok, any()} | {:error, any()}
Deletes record with key in KeyValueSet. See Ets.Set.delete/2.
delete_all!(Ets.Set.KeyValueSet.t()) :: any()
Same as delete_all/1 but unwraps or raises on error.
delete_all(Ets.Set.KeyValueSet.t()) :: {:ok, any()} | {:error, any()}
Deletes all records in KeyValueSet. See Ets.Set.delete_all/1.
Same as first/1 but unwraps or raises on error.
first(Ets.Set.KeyValueSet.t()) :: {:ok, any()} | {:error, any()}
Returns first key in KeyValueSet. See Ets.Set.first/1.
get!(Ets.Set.KeyValueSet.t(), any(), any()) :: any()
Same as get/3 but unwraps or raises on error
get(Ets.Set.KeyValueSet.t(), any(), any()) :: {:ok, any()} | {:error, any()}
Returns value for specified key or the provided default (nil if not specified) if no record found.
Examples
iex> KeyValueSet.new!()
iex> |> KeyValueSet.put!(:a, :b)
iex> |> KeyValueSet.put!(:c, :d)
iex> |> KeyValueSet.put!(:e, :f)
iex> |> KeyValueSet.get(:c)
{:ok, :d}
get_table!(Ets.Set.KeyValueSet.t()) :: Ets.table_reference()
Same as get_table/1 but unwraps or raises on error.
get_table(Ets.Set.KeyValueSet.t()) :: {:ok, Ets.table_reference()} | {:error, any()}
Returns underlying :ets table reference. See Ets.Set.get_table/1.
has_key!(Ets.Set.KeyValueSet.t(), any()) :: any()
Same as has_key/2 but unwraps or raises on error.
has_key(Ets.Set.KeyValueSet.t(), any()) :: {:ok, any()} | {:error, any()}
Determines if specified key exists in KeyValueSet. See Ets.Set.has_key/2.
info!(Ets.Set.KeyValueSet.t(), boolean()) :: keyword()
Same as info/2 but unwraps or raises on error.
info(Ets.Set.KeyValueSet.t(), boolean()) :: {:ok, keyword()} | {:error, any()}
Returns info on set. See Ets.Set.info/2.
Same as last/1 but unwraps or raises on error.
last(Ets.Set.KeyValueSet.t()) :: {:ok, any()} | {:error, any()}
Returns last key in KeyValueSet. See Ets.Set.last/1.
Same as new/1 but unwraps or raises on error.
new(set_options()) :: {:error, any()} | {:ok, Ets.Set.KeyValueSet.t()}
Creates new Key Value Set module with the specified options.
Possible Options can be found in Ets.Set with the difference that specifying a keypos
will result in an error.
Examples
iex> {:ok, kvset} = KeyValueSet.new(ordered: true,read_concurrency: true, compressed: false)
iex> KeyValueSet.info!(kvset)[:read_concurrency]
true
# Named :ets tables via the name keyword
iex> {:ok, kvset} = KeyValueSet.new(name: :my_ets_table)
iex> KeyValueSet.info!(kvset)[:name]
:my_ets_table
next!(Ets.Set.KeyValueSet.t(), any()) :: any()
Same as next/2 but unwraps or raises on error.
next(Ets.Set.KeyValueSet.t(), any()) :: {:ok, any()} | {:error, any()}
Returns next key in KeyValueSet. See Ets.Set.next/2.
previous!(Ets.Set.KeyValueSet.t(), any()) :: any()
Same as previous/2 but unwraps or raises on error.
previous(Ets.Set.KeyValueSet.t(), any()) :: {:ok, any()} | {:error, any()}
Returns previous key in KeyValueSet. See Ets.Set.previous/2.
put!(Ets.Set.KeyValueSet.t(), any(), any()) :: Ets.Set.KeyValueSet.t()
Same as put/3 but unwraps or raises on error.
Puts given value into table for given key.
Examples
iex> kvset = KeyValueSet.new!(ordered: true)
iex> {:ok, kvset} = KeyValueSet.put(kvset, :a, :b)
iex> KeyValueSet.get!(kvset, :a)
:b
put_new!(Ets.Set.KeyValueSet.t(), any(), any()) :: Ets.Set.KeyValueSet.t()
Same as put_new/3 but unwraps or raises on error.
put_new(Ets.Set.KeyValueSet.t(), any(), any()) :: {:ok, Ets.Set.KeyValueSet.t()} | {:error, any()}
Same as put/3 but doesn’t put record if the key already exists.
Examples
iex> set = KeyValueSet.new!(ordered: true)
iex> {:ok, _} = KeyValueSet.put_new(set, :a, :b)
iex> {:ok, _} = KeyValueSet.put_new(set, :a, :c) # skips due toduplicate :a key
iex> KeyValueSet.to_list!(set)
[{:a, :b}]
to_list!(Ets.Set.KeyValueSet.t()) :: any()
Same as to_list/1 but unwraps or raises on error.
to_list(Ets.Set.KeyValueSet.t()) :: {:ok, any()} | {:error, any()}
Returns contents of table as a list. See Ets.Set.to_list/1.
wrap_existing!(Ets.table_identifier()) :: Ets.Set.KeyValueSet.t()
Same as wrap_existing/1 but unwraps or raises on error.
wrap_existing(Ets.table_identifier()) :: {:ok, Ets.Set.KeyValueSet.t()} | {:error, any()}
Wraps an existing :ets :set or :ordered_set in a KeyValueSet struct.
Examples
iex> :ets.new(:my_ets_table, [:set, :named_table])
iex> {:ok, set} = KeyValueSet.wrap_existing(:my_ets_table)
iex> KeyValueSet.info!(set)[:name]
:my_ets_table