Geminix.Cache (geminix v0.2.0)
Summary
Functions
Defines a function with automatically cached arguments.
Execute a function (fun) and cache the result if successful.
The function should return {:ok, result} on success and anything
else (probably an {:error, reason} tuple) on failure.
This function returns the full {:ok, ...} or {:error, ...} tuple.
Failed results won't be cached.
Functions
Defines a function with automatically cached arguments.
Results from this function will be cached to disk, so the results will be persisted between program runs.
Example
defcached f(a, b, c) do
...
end
Execute a function (fun) and cache the result if successful.
The function should return {:ok, result} on success and anything
else (probably an {:error, reason} tuple) on failure.
This function returns the full {:ok, ...} or {:error, ...} tuple.
Failed results won't be cached.
The function call must be tagged with the {module, function, args},
so that the result can be retreived from the cache.
This function doesn't check that the function actually uses
the provided arguments, that is the responsability of the user.
If you want {:error, reason} to be treated as a success,
wrap it in an {:ok, {:error, reason}} tuple in the function
you call and extract the value later.