View Source Memoize (memoize v1.4.2)

Module documentation for Memoize.

Link to this section Summary

Link to this section Functions

Link to this macro

defmemo(call, expr_or_opts \\ nil)

View Source (macro)

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

def __foo_memoize(0, y) do
  y
end

def __foo_memoize(x, y) when x == 1 do
  y * z
end

def __foo_memoize(x, y, z \\ 0) when x == 2 do
  y * z
end
Link to this macro

defmemo(call, opts, expr)

View Source (macro)
Link to this macro

defmemop(call, expr_or_opts \\ nil)

View Source (macro)
Link to this macro

defmemop(call, opts, expr)

View Source (macro)

See Memoize.Cache.garbage_collect/0.

Link to this function

invalidate(module, function)

View Source
Link to this function

invalidate(module, function, arguments)

View Source