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
aandbshare 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 thesvdfunction.Clearing a variable does not clear the cache associated with the input function. To clear the cache for a
MemoizedFunctionobject that no longer exists in the workspace, create a newMemoizedFunctionobject to the same function, and use theclearCachefunction on the new object. Alternatively, you can clear caches for allMemoizedFunctionobjects using theclearAllMemoizedCachesfunction.
Version History
Introduced in R2017a