Exconf v0.1.1 Exconfig.Cache View Source

PRIVATE MODULE -- Do not use this module directely but through Exconfig API only.

The module implements a GenServer handling the state of the cache.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Clear the current cache.

Get the entire current cache as a Map.

Find a given key or return {:error, :key_not_found}

Start link function used from Exconfig.Application to start a single instance of this Cache-Server as a supervised worker.

Update the given key in the cache with a new value. Also inserts a new key/value if it not exists yet.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Clear the current cache.

Example

iex> Exconfig.Cache.clear!()
iex> Exconfig.get()
%{}

Get the entire current cache as a Map.

Example

iex> Exconfig.clear_cache!()
iex> Exconfig.Cache.get()
%{}

iex> Exconfig.clear_cache!()
iex> Exconfig.get(:logger, :level )
iex> Exconfig.Cache.get()
%{{:logger, :level} => :debug}
Link to this function

lookup(application_key, key, default) View Source

Find a given key or return {:error, :key_not_found}

Start link function used from Exconfig.Application to start a single instance of this Cache-Server as a supervised worker.

Link to this function

update(application_key, key, value) View Source

Update the given key in the cache with a new value. Also inserts a new key/value if it not exists yet.

Example

iex> Exconfig.Cache.clear!()
iex> Exconfig.get(:logger,:level)
iex> Exconfig.Cache.update(:logger,:level,:new_level)
iex> Exconfig.get()
%{{:logger, :level} => :new_level}