ecache is a erlang in-memory TTL cache base on ETS.
Just add ecache
dep to you rebar.config
:
{deps, [
{ecache, ".*",
{git, "https://github.com/JasonZhu/ecache.git", {branch, "master"}}}
]}.
And ecache
settings in your app.config file:
{ecache,[
{ets_threshold, 0.85},
{ets_maxsize, 209715200} %% 200*1024*1024 = 200M
]}
ecache:set(Key, Val, TTL) -> ok.
ecache:get(Key) -> {ok, Val} | {error, Reason}.
ecache:delete(Key) -> ok.