Module:Memoizer/doc

Utility module which allows most functions to be memoized based on their arguments; the memoized function caches results for each unique set of arguments, avoiding expensive recomputations if the function is known to be pure, such as Cargo queries. The module exposes a single function,, which accepts two arguments:


 * func: The function to be memoized. It may accept any number of arguments, and it may return . It must not return more than one value (extra values are discarded) or call itself (recursive functions cannot access memoized versions of themselves).
 * keyfn: If provided, the memoizer calls this object using the passed arguments to construct a key for the arguments; otherwise, the first argument is used as the key. Invocations that produce the same key will return the same cached value. If the returned value is a table or userdata, it is referenced by all invocations of the same key and never duplicated.