mala

Types

An ETS “bag” type table.

This in memory table can have multiple values for each key.

See the Erlang documentation for more information: https://www.erlang.org/doc/apps/stdlib/ets.html

pub type BagTable(k, v)

Values

pub fn delete(
  table: BagTable(k, v),
  key: k,
  value: v,
) -> Result(Nil, Nil)

Delete a key-value pair from the table.

This function will return an error if the bag has been dropped, either explicitly with drop_table or implicitly by the owner process terminating.

pub fn delete_key(
  table: BagTable(k, v),
  key: k,
) -> Result(Nil, Nil)

Delete all values for the given key in the table.

This function will return an error if the bag has been dropped, either explicitly with drop_table or implicitly by the owner process terminating.

pub fn delete_value(
  table: BagTable(k, v),
  value: v,
) -> Result(Int, Nil)

Delete all instances of a given value from the table, no matter what key they are stored under.

This performs a full table scan so is slower than the other operations in this module.

This function will return an error if the bag has been dropped, either explicitly with drop_table or implicitly by the owner process terminating.

pub fn drop_table(table: BagTable(k, v)) -> Nil

Drop a table, freeing the memory it used.

Any attempt to use a table after it was dropped will result in an error.

pub fn get(table: BagTable(k, v), key: k) -> Result(List(v), Nil)

Key all values for a given key in the table.

This function will return an error if the bag has been dropped, either explicitly with drop_table or implicitly by the owner process terminating.

pub fn insert(
  table: BagTable(k, v),
  key: k,
  value: v,
) -> Result(Nil, Nil)

Insert a value for the given key in the table. If the key already has this value then there will be no change.

This function will return an error if the bag has been dropped, either explicitly with drop_table or implicitly by the owner process terminating.

pub fn new() -> BagTable(k, v)

Create a new bag.

The process that calls this function is the owner of the ETS table, and the table will be dropped when the owner process terminates.

The access control is set to allow all processes to read and write to the table.

See new_protected and new_private for other access control options.

pub fn new_private() -> BagTable(k, v)

Create a new bag.

The process that calls this function is the owner of the ETS table, and the table will be dropped when the owner process terminates.

The access control is set so only the process that created the table can read from and write to it. All other processes cannot access the table.

See new and new_protected for other access control options.

pub fn new_protected() -> BagTable(k, v)

Create a new bag.

The process that calls this function is the owner of the ETS table, and the table will be dropped when the owner process terminates.

The access control is set so only the process that created the table can write to it. All other processes can read from it.

See new and new_private for other access control options.

Search Document