View Source Sanity.Cache.CacheServer (sanity_cache v0.3.1)
For caching results in an ETS table. A single instance of this GenServer is started automatically.
Link to this section Summary
Functions
Like put_table/3
, except uses GenServer.cast/2
.
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 a table with the given names. pairs
must be a map or a list of key value
pairs like [{:my_key, :my_value}]
.
Link to this section Functions
Like put_table/3
, except uses GenServer.cast/2
.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Deletes a table if it exists. Returns :ok
or {:error, :no_table}
.
examples
Examples
iex> delete_table(:nonexistent_doctest_table)
{:error, :no_table}
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
Creates or replaces a table with the given names. pairs
must be a map or a list of key value
pairs like [{:my_key, :my_value}]
.
examples
Examples
iex> put_table(:doctest_table, [{"key", "value"}])
:ok