Copyright © 2009-2016 Marc Worrell, Arjan Scherpenisse
Behaviours: gen_server.
Authors: Marc Worrell (marc@worrell.nl).
depcache_server() = pid() | atom()
dependencies() = [key()]
key() = any()
max_age_secs() = non_neg_integer()
memo_fun() = function() | mfa() | {module(), atom()}
| cleanup/1 | Cleanup process for the depcache. |
| cleanup/5 | |
| code_change/3 | |
| flush/1 | Flush all keys from the caches. |
| flush/2 | Flush the key and all keys depending on the key. |
| flush_process_dict/0 | Flush all items memoized in the process dictionary. |
| get/2 | Fetch the key from the cache, return the data or an undefined if not found (or not valid). |
| get/3 | Fetch the key from the cache, return the data or an undefined if not found (or not valid). |
| get_subkey/3 | Fetch the key from the cache, return the data or an undefined if not found (or not valid). |
| get_wait/2 | Fetch the key from the cache, when the key does not exist then lock the entry and let the calling process insert the value. |
| handle_call/3 | Return the ets tables used by the cache. |
| handle_cast/2 | |
| handle_info/2 | |
| in_process/1 | Enable or disable the in-process caching using the process dictionary. |
| in_process_server/1 | Check if we use a local process dict cache. |
| init/1 | Initialize the depcache. |
| memo/2 | |
| memo/3 | |
| memo/4 | |
| memo/5 | |
| set/3 | Add the key to the depcache, hold it for 3600 seconds and no dependencies. |
| set/4 | Add the key to the depcache, hold it for MaxAge seconds and no dependencies. |
| set/5 | Add the key to the depcache, hold it for MaxAge seconds and check the dependencies. |
| size/1 | Return the total memory size of all stored terms. |
| start_link/1 | Start a depcache process. |
| start_link/2 | Start a named depcache process. |
| terminate/2 |
cleanup(Cleanup_state) -> any()
Cleanup process for the depcache. Periodically checks a batch of depcache items for their validity. Asks the depcache server to delete invalidated items. When the load of the data table is too high then This cleanup process starts to delete random entries. By using a random delete we don't need to keep a LRU list, which is a bit expensive.
cleanup(Cleanup_state, SlotNr, Now, Mode, Ct) -> any()
code_change(OldVersion, State, Extra) -> any()
flush(Server::depcache_server()) -> ok
Flush all keys from the caches
flush(Key::key(), Server::depcache_server()) -> ok
Flush the key and all keys depending on the key
flush_process_dict() -> any()
Flush all items memoized in the process dictionary.
get(Key::key(), Server::depcache_server()) -> {ok, any()} | undefined
Fetch the key from the cache, return the data or an undefined if not found (or not valid)
get(Key::key(), SubKey::key(), Server::depcache_server()) -> {ok, any()} | undefined
Fetch the key from the cache, return the data or an undefined if not found (or not valid)
get_subkey(Key::key(), SubKey::key(), Server::depcache_server()) -> {ok, any()} | undefined
Fetch the key from the cache, return the data or an undefined if not found (or not valid)
get_wait(Key::key(), Server::depcache_server()) -> {ok, any()} | undefined
Fetch the key from the cache, when the key does not exist then lock the entry and let the calling process insert the value. All other processes requesting the key will wait till the key is updated and receive the key's new value.
handle_call(X1, From, State) -> any()
Return the ets tables used by the cache
handle_cast(Msg, State) -> any()
handle_info(Msg, State) -> any()
in_process(X1::boolean()) -> ok
Enable or disable the in-process caching using the process dictionary
in_process_server(Server::depcache_server()) -> boolean()
Check if we use a local process dict cache.
init(Config) -> {ok, State}
Initialize the depcache. Creates ets tables for the deps, meta and data. Spawns garbage collector.
memo(Fun::memo_fun(), Server::depcache_server()) -> any()
memo(Fun::memo_fun(), MaxAge::max_age_secs() | key(), Server::depcache_server()) -> any()
memo(Fun::memo_fun(), Key::max_age_secs(), MaxAge::key(), Server::depcache_server()) -> any()
memo(Fun::memo_fun(), Key::max_age_secs(), MaxAge::key(), Dep::dependencies(), Server::depcache_server()) -> any()
set(Key::key(), Data::any(), Server::depcache_server()) -> ok
Add the key to the depcache, hold it for 3600 seconds and no dependencies
set(Key::key(), Data::any(), MaxAge::max_age_secs(), Server::depcache_server()) -> ok
Add the key to the depcache, hold it for MaxAge seconds and no dependencies
set(Key::key(), Data::any(), MaxAge::max_age_secs(), Depend::dependencies(), Server::depcache_server()) -> ok
Add the key to the depcache, hold it for MaxAge seconds and check the dependencies
size(Server::depcache_server()) -> non_neg_integer()
Return the total memory size of all stored terms
start_link(Config::proplists:proplist()) -> {ok, pid()} | ignore | {error, term()}
Start a depcache process.
For Config, you can pass: {callback, {Module, Function, Arguments}}: depcache event callback {memory_max, MaxMemoryInMB}: number of MB to limit depcache size at.start_link(Name::atom(), Config::proplists:proplist()) -> {ok, pid()} | ignore | {error, term()}
Start a named depcache process.
For Config, you can pass: {callback, {Module, Function, Arguments}}: depcache event callback {memory_max, MaxMemoryInMB}: number of MB to limit depcache size at.terminate(Reason, State) -> any()
Generated by EDoc