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.