clearCache
Clear cache for MemoizedFunction
object
Syntax
Description
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.
Examples
Input Arguments
Tips
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
andb
share a cache and have the same value for cache size.Clearing the cache fora = memoize(@svd); b = memoize(@svd);
b
(b.clearCache
) also clears the cache fora
, and any other variables that memoize thesvd
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 newMemoizedFunction
object to the same function, and use theclearCache
function on the new object. Alternatively, you can clear caches for allMemoizedFunction
objects using theclearAllMemoizedCaches
function.
Version History
Introduced in R2017a