memoize v1.2.0 Memoize
Link to this section Summary
Functions
Define the memoized function
Link to this section Functions
Link to this function
cache_strategy()
Define the memoized function.
Below code:
defmemo foo(0, y) do
y
end
defmemo foo(x, y) when x == 1 do
y * z
end
defmemo foo(x, y, z \\ 0) when x == 2 do
y * z
end
is converted to:
def foo(t1, t2) do
Memoize.Cache.get_or_run({__MODULE__, :foo, [t1, t2]}, fn -> __foo_memoize(t1, t2) end)
end
def foo(t1, t2, t3) do
Memoize.Cache.get_or_run({__MODULE__, :foo, [t1, t2, t3]}, fn -> __foo_memoize(t1, t2, t3) end)
end
defmemo __foo_memoize(0, y) do
y
end
defmemo __foo_memoize(x, y) when x == 1 do
y * z
end
defmemo __foo_memoize(x, y, z \\ 0) when x == 2 do
y * z
end
Link to this function
garbage_collect()
Link to this function
invalidate()
Link to this function
invalidate(module)
Link to this function
invalidate(module, function)
Link to this function
invalidate(module, function, arguments)