melpon / memoize

A method caching macro for elixir using CAS on ETS.
https://hex.pm/packages/memoize
MIT License
189 stars 12 forks source link

List argument causes argument error #7

Closed sato-s closed 5 years ago

sato-s commented 5 years ago

Hi, I tried to pass list as an argument, but was unsuccessful.
Can I pass list as an argument?

code

defmodule Sample do
  use Memoize
  defmemo my_fun(list) do
    list
  end
end

Sample.my_fun([1,2])

error

$ mix compile
Compiling 1 file (.ex)

== Compilation error in file lib/sample.ex ==
** (ArgumentError) argument error
    (stdlib) :ets.lookup(Memoize.CacheStrategy.Default, {Sample, :my_fun, [[1, 2]]})
    lib/memoize/cache.ex:99: Memoize.Cache.do_get_or_run/3
    (elixir) lib/kernel/parallel_compiler.ex:206: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
melpon commented 5 years ago

:memoize application is not started.

Try this:

defmodule Sample do
  use Memoize
  defmemo my_fun(list) do
    list
  end
end

Application.ensure_all_started(:memoize)
Sample.my_fun([1,2])
sato-s commented 5 years ago

Hi, thank you. Seems like I am totally newbie to elixir.