nova_cache (nova v0.8.1) View Source
nova_cache is a basic in-memory cache that uses ETS as backend. When a cache is initialized a process is spawned and associated for that particular cache. This process is kept alive through out the whole life time of the cache and is the owner of the ETS table that is used for storage.
The TTLs is implemented using erlang:send_after/4.Link to this section Summary
Functions
Deletes an entry in the cache.
Removes all entries for a cache.
Gets an entriy from the cache.
Initializes a cache.
Removes the cache and frees up the memory.
Same as set/4 but uses the default time for TTL which is defined as 3600000 (3600 seconds)
Sets a cache value with a TTL. To refresh an entry one need to use the set-function again.
Starts the server
Link to this section Functions
Specs
delete(Cache :: atom(), Key :: term()) -> ok.
Specs
flush(Cache :: atom()) -> ok.
Specs
get(Cache :: atom(), Key :: term()) -> {ok, Value :: any()} | {error, not_found}.
Specs
init_cache(Cachename :: atom()) -> {ok, Child} | {ok, Child, Info :: term()} | {error, {already_started, pid()} | {shutdown, term()} | term()} when Child :: undefined | pid().
Specs
remove_cache(Cachename :: atom()) -> ok.
Specs
set(Cache :: atom(), Key :: term(), Value :: any()) -> ok.
Specs
set(Cache :: atom(), Key :: term(), Value :: any(), TTL :: non_neg_integer()) -> ok.
Specs
start_link(Cache :: atom()) -> {ok, Pid :: pid()} | {error, Error :: {already_started, pid()}} | {error, Error :: term()} | ignore.