View Source CMS.CacheServer (cms v0.8.0)

For caching results in an ETS table. A single instance of this GenServer is started automatically.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Deletes a table if it exists. Returns :ok or {:error, :no_table}.

Fetches a value from the cache. Returns one of the following

Creates or replaces zero or more tables.

Returns a list of ETS table names managed by the cache.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

delete_table(pid \\ CMS.CacheServer, table)

View Source

Deletes a table if it exists. Returns :ok or {:error, :no_table}.

examples

Examples

iex> delete_table(:nonexistent_table)
{:error, :no_table}
Link to this function

fetch(pid \\ CMS.CacheServer, table, key)

View Source

Fetches a value from the cache. Returns one of the following

  • {:ok, value} if the item is found
  • {:error, :no_table} if the table doesn't exist
  • {:error, :not_found} if the table exists but doesn't contain the specified key
Link to this function

put_tables(pid \\ CMS.CacheServer, tables)

View Source

Creates or replaces zero or more tables.

examples

Examples

iex> put_tables(table_1: [{"key", "value"}], table_2: %{"key" => "value"})
:ok
Link to this function

put_tables_on_all_nodes(pid \\ CMS.CacheServer, tables)

View Source

See GenServer.start_link/3.

Link to this function

table_names(pid \\ CMS.CacheServer)

View Source

Returns a list of ETS table names managed by the cache.