Exconf v0.1.0 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.
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
child_spec(init_arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
clear!() View Source
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}
lookup(application_key, key, default) View Source
Find a given key or return {:error, :key_not_found}
start_link(args) View Source
Start link function used from Exconfig.Application
to
start a single instance of this Cache-Server as a supervised
worker.
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}