nova_cache (NOVA vv0.8.0)
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
Link to this function
delete(Cache, Key)
Specs
delete(Cache :: atom(), Key :: term()) -> ok.
Link to this function
flush(Cache)
Specs
flush(Cache :: atom()) -> ok.
Link to this function
get(Cache, Key)
Specs
get(Cache :: atom(), Key :: term()) -> {ok, Value :: any()} | {error, not_found}.
Link to this function
init_cache(Cachename)
Specs
init_cache(Cachename :: atom()) ->
{ok, Child} |
{ok, Child, Info :: term()} |
{error, {already_started, pid()} | {shutdown, term()} | term()}
when Child :: undefined | pid().
Link to this function
remove_cache(Cachename)
Specs
remove_cache(Cachename :: atom()) -> ok.
Link to this function
set(Cache, Key, Value)
Specs
set(Cache :: atom(), Key :: term(), Value :: any()) -> ok.
Link to this function
set(Cache, Key, Value, TTL)
Specs
set(Cache :: atom(), Key :: term(), Value :: any(), TTL :: non_neg_integer()) -> ok.
Link to this function
start_link(Cache)
Specs
start_link(Cache :: atom()) ->
{ok, Pid :: pid()} |
{error, Error :: {already_started, pid()}} |
{error, Error :: term()} |
ignore.