Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LRU example doesn't work #58

Closed
fredcallaway opened this issue Jul 24, 2020 · 3 comments
Closed

LRU example doesn't work #58

fredcallaway opened this issue Jul 24, 2020 · 3 comments

Comments

@fredcallaway
Copy link

Forgive me if I'm missing something obvious...

julia> using Memoize, LRUCache

(@v1.4) pkg> status Memoize LRUCache
Status `~/.julia/environments/v1.4/Project.toml`
  [8ac3fa9e] LRUCache v1.1.0
  [c03570c3] Memoize v0.4.3

julia> @memoize LRU{Tuple{Any,Any},Any}(maxsize=2) function x(a, b)
           println("Running")
           a + b
       end
ERROR: LoadError: MethodError: objects of type LRU{Tuple{Any,Any},Any} are not callable
Stacktrace:
 [1] top-level scope at REPL[12]:1
 [2] eval(::Module, ::Any) at ./boot.jl:331
 [3] @memoize(::LineNumberNode, ::Module, ::Vararg{Any,N} where N) at /Users/fred/.julia/packages/Memoize/V4Yuh/src/Memoize.jl:51
in expression starting at REPL[12]:1
@fredcallaway
Copy link
Author

I guess this package isn't being maintained? For other users, the simple fix is just to wrap the LRU initialization in an anonymous function:

@memoize (() -> LRU{Tuple{Any,Any},Any}(maxsize=2)) function x(a, b)
    println("Running")
    a + b
end

@kalmarek
Copy link

also JuliaCollections/LRUCache.jl#18
the packages don't seem to be actively maintained? @kmsquire ?

@ericphanson
Copy link
Member

I think this was fixed, works for me now:

julia> @memoize LRU{Tuple{Any,Any},Any}(maxsize=2) function x(a, b)
           println("Running")
           a + b
       end
x (generic function with 1 method)

julia> x(1,2)
Running
3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants