clearCache
Empties the cache of one memoized function.
Category: Software Development Tools > Performance and Memory
Syntax
clearCache(m)
Removes every stored result from the memoized function object m.
Description
clearCache is a method of memoized function objects. It deletes the cached inputs and outputs of m and resets its statistics, but leaves m memoized: the next call computes the result again and stores it.
Other memoized functions are not affected. To clear all of them at once use clearAllMemoizedCaches.
Input arguments
m- A
matlab.lang.MemoizedFunctionobject returned bymemoize.
Example
Clear one cache
m = memoize(@(x) x + 1);
m(1); m(1); m(2);
s = stats(m);
fprintf('hits %d, misses %d\n', s.Cache.TotalHits, s.Cache.TotalMisses)
clearCache(m)
s = stats(m);
fprintf('hits %d, misses %d\n', s.Cache.TotalHits, s.Cache.TotalMisses)
Output
hits 1, misses 2
hits 0, misses 0