# NitroCache

NitroCache is a fork of [simple_cache](
modified specifically for the needs of integration with the [Nitrogen Web

The updated code now has a separate process to handle the expirations, which is
a regular `gen_server`. To start it, just do:


## Create a cache


## Getting a key

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"),

## Flushing the cache


## Flushing a key

    nitro_cache:flush(my_cache_name, my_key).

## Changes:

### Version 0.4.0

+ Renamed to NitroCache to avoid a name clash (simple_cache is already taken
+ Requesting a key from a bucket if it has not yet been initialized will
  automatically instantiate that bucket.
+ NitroCache introduced a mutex system to prevent recalculating the same
  slow-calculating key when multiple requests come in at same time.  When the
  key's value is calculated, it will return the result to all the waiting
+ Added a `cache_exists/1` function.
+ Added a `set/4` function.
+ Converted to rebar3

### Version =< 0.3

These earlier versions are the simple_cache versions.