Copyright © 2015, Tuncer Ayaz
Behaviours: gen_server.
Authors: Tuncer Ayaz.
error() = {error, reason()}
fun_args() = list()
fun_name() = atom()
reason() = term()
start_link_res() = start_res()
start_res() = {ok, pid()} | ignore | error()
| call/2 | Call function and memoize result. |
| call/3 | Call function and memoize result. |
| start/0 | Start the server. |
| start_link/0 | Start the server. |
| stop/0 | Stop the server. |
call(F::function(), A::fun_args()) -> term()
Call function and memoize result
Instead of
Res = Fun(A1, A2, [List1])
you call
Res = memo:call(Fun, [A1, A2, [List1]])
or instead of
Res = mod:expensive_function(A1, A2, [List1])
you call
Res = memo:call(fun mod:expensive_function/3, [A1, A2, [List1]])
and any subsequent call will fetch the cached result and avoid the computation.
This is of course only useful for expensive computations that are known to produce the same result given same arguments. It's worth mentioning that your call should be side-effect free, as naturally those won't be replayed.call(M::module(), F::fun_name(), A::fun_args()) -> term()
Call function and memoize result
Instead of
Res = mod:expensive_function(A1, A2, [List1])
you call
Res = memo:call(mod, expensive_function, [A1, A2, [List1]])
and any subsequent call will fetch the cached result and avoid the computation.
This is of course only useful for expensive computations that are known to produce the same result given same arguments. It's worth mentioning that your call should be side-effect free, as naturally those won't be replayed.%%start() -> start_res()
Start the server
start_link() -> start_link_res()
Start the server
stop() -> any()
Stop the server
Generated by EDoc