Behaviours: gen_server.
lru_option() = {evict_fun, function()} | {spawn_opt, list()}
| add/3 | adds a value to the cache. |
| contains/2 | check if the key is in the cache. |
| contains_or_add/3 | checks if a key is in the cache (without updating the recent-ness or deleting it for being stale), if not, adds the value. |
| get/2 | lookup a key's value from the cache. |
| get/3 | lookup a key's value from the cache. |
| info/1 | get cache info. |
| keys/1 | return all the keys from the cache. |
| peek/2 | Returns the key value (or undefined if not found) without updating the "recently used"-ness of the key. |
| peek/3 | Returns the key value (or undefined if not found) without updating the "recently used"-ness of the key. |
| purge/1 | purge all items from the cache. |
| remove/2 | remove a key from the cache. |
| remove_oldest/1 | remove the oldest item from the cache. |
| resize/2 | resize of the cache. |
| set_size/2 | change the size of the cache. |
| size/1 | get the number of items in the cache. |
| start/1 | creates an LRU of the given size. |
| start/2 | creates an LRU of the given size
Options are:
- {evict_fun, Fun} a function that will received the evicted key value
"fun(Key, Value)". |
| start/3 | creates an LRU of the given size with a registered name. |
| start_link/1 | creates an LRU of the given size as part of a supervision tree. |
| start_link/2 | creates an LRU of the given size as part of a supervision tree. |
| start_link/3 | creates an LRU of the given size as part of a supervision tree with a registered name. |
| stop/1 | stop the LRU cache. |
add(Cache::pid(), Key::term(), Value::term()) -> true | false
adds a value to the cache. Returns true if an eviction occured.
contains(Cache::pid(), Key::term()) -> true | false
check if the key is in the cache
contains_or_add(Cache::pid(), Key::term(), Value::term()) -> {Exists::boolean(), Evict::boolean()}
checks if a key is in the cache (without updating the recent-ness or deleting it for being stale), if not, adds the value. Returns whether found and whether an eviction occurred.
get(Cache::pid(), Key::term()) -> term() | undefined
lookup a key's value from the cache. Return undefined if it's not found.
get(Cache::pid(), Key::term(), Default::term()) -> term()
lookup a key's value from the cache. Return the Default value if it's not found.
info(Cache::pid()) -> Info::list()
get cache info
keys(Cache::pid()) -> [term()]
return all the keys from the cache
peek(Cache::pid(), Key::term()) -> term() | undefined
Returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
peek(Cache::pid(), Key::term(), Default::term()) -> term() | undefined
Returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
purge(Cache::pid()) -> ok
purge all items from the cache.
remove(Cache::pid(), Key::term()) -> ok
remove a key from the cache
remove_oldest(Cache::pid()) -> ok
remove the oldest item from the cache
resize(Cache::pid(), Size::non_neg_integer()) -> ok
resize of the cache
set_size(Cache::pid(), Size::non_neg_integer()) -> ok
change the size of the cache
size(Cache::pid()) -> non_neg_integer()
get the number of items in the cache
start(Size::non_neg_integer()) -> {ok, pid()} | {error, term()}
creates an LRU of the given size
start(Size::non_neg_integer(), Opts::[lru_option()]) -> {ok, pid()} | {error, term()}
creates an LRU of the given size
Options are:
- {evict_fun, Fun} a function that will received the evicted key value
"fun(Key, Value)".
- {spawn_opts, Opts} the spawn options. see erlang:spawn_opt/2 for
more informations.
start(Name::{local, Name::atom()} | {global, GlobalName::term()} | {via, ViaName::term()}, Size::non_neg_integer(), Opts::[lru_option()]) -> {ok, pid()} | {error, term()}
creates an LRU of the given size with a registered name
start_link(Size::non_neg_integer()) -> {ok, pid()} | {error, term()}
creates an LRU of the given size as part of a supervision tree
start_link(Size::non_neg_integer(), Opts::[lru_option()]) -> {ok, pid()} | {error, term()}
creates an LRU of the given size as part of a supervision tree
start_link(Name::{local, Name::atom()} | {global, GlobalName::term()} | {via, ViaName::term()}, Size::non_neg_integer(), Opts::[lru_option()]) -> {ok, pid()} | {error, term()}
creates an LRU of the given size as part of a supervision tree with a registered name.
stop(Cache::pid()) -> ok
stop the LRU cache
Generated by EDoc