Caching Server for Nitrogen Web Framework
APACHE-2.0 License
NitroCache is a fork of simple_cache modified specifically for the needs of integration with the Nitrogen Web Framework.
The updated code now has a separate process to handle the expirations, which is
a regular gen_server
. To start it, just do:
nitro_cache_expirer:start_link().
nitro_cache:init(my_cache_name).
The following call will lookup my_key in the cache named my_cache_name, and on a MISS will call the given fun, caching its result for 3600000 milliseconds.
nitro_cache:get(my_cache_name, 3600000, my_key, fun() ->
io:format("This fun will be called on a cache miss~n"),
timer:sleep(5000)
this_value_will_be_cached
end).
nitro_cache:flush(my_cache_name).
nitro_cache:flush(my_cache_name, my_key).
cache_exists/1
function.set/4
function.cache_exists/1
function.set/4
function.