julia> using KissCaches
julia> f(x) = (println("hi"); return x)
f (generic function with 1 method)
julia> @cached f(1)
hi
1
julia> @cached f(1)
1
julia> cache = Dict() # customize cache
Dict{Any,Any}()
julia> @cached cache f(1)
hi
1
julia> @cached cache f(1)
1
julia> empty!(cache)
Dict{Any,Any}()
julia> @cached cache f(1)
hi
1
There are multiple excellent alternatives for caching function calls. Most are more sophisticted and work by altering the function definition. KissCaches on the other hand is really simple and alters the function call. See also: