Clear cache for MemoizedFunction
object
clearCache(
clears
the cache for a mfcn
)MemoizedFunction
object.
The memoization of a function is associated with the input function
and not with the MemoizedFunction
object. Therefore,
clearing a variable does not clear the cache associated with the input
function.
A MemoizedFunction
object is not aware of
updates to the underlying function. If you modify the function associated
with the memoized function, use clearCache
to
clear the cache.
Two variables that memoize the same function share
a cache and object property values, such as cache size. In the following
example, the variables a
and b
share
a cache and have the same value for cache size.
a = memoize(@svd); b = memoize(@svd);
b
(b.clearCache
)
also clears the cache for a
, and any other variables
that memoize the svd
function.Clearing a variable does not clear the cache associated
with the input function. To clear the cache for a MemoizedFunction
object
that no longer exists in the workspace, create a new MemoizedFunction
object
to the same function, and use the clearCache
function
on the new object. Alternatively, you can clear caches for all MemoizedFunction
objects
using the clearAllMemoizedCaches
function.