Memoize (FlintUI v0.1.0)
Simple FastGlobal
based memoization module to cache function results.
Summary
Functions
Link to this function
get(key)
See FastGlobal.get/1
.
Link to this function
put(key, value)
See FastGlobal.put/2
.
Link to this function
resolve(key, resolver)
Resolves the given key using the given resolver function.
If the key is not found in the cache, the resolver function is called and the result is stored in the cache. If the key is found in the cache, the cached value is returned.
Examples
defmodule MyModule do
def my_function(arg1, arg2) do
Memoize.resolve({__MODULE__, :my_function, [arg1, arg2]}, fn ->
# Do some expensive computation here
end)
end
end