Small erlang simple cache using ETS to wrap your methods with
Branch: master
Clone or download
marcelog Merge pull request #3 from freepenguins/master
Application libraries shouldn't need this
Latest commit 2406072 Dec 6, 2013
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Application libraries shouldn't need this Dec 4, 2013
LICENSE adding license file Mar 5, 2013
rebar Initial commit Mar 5, 2013
rebar.config Initial commit Mar 5, 2013


This is the source code for this post, a simple ETS based cache.

For the original version, see the 0.1 tag

Using it

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.

simple_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

simple_cache:flush(my_cache_name, my_key).