title: The best way to construct a function with memory
body: <p>Good day,</p>
  
  <p>I have some very slooooow and complicated function, say <code>f[x,y]</code>. And I need to construct detailed <code>ContourPlot</code> of it. Moreover the function <code>f[x,y]</code> sometimes fails due to lack of physical memory. In such cases I have to stop evaluation and investigate the problem case of the point {x,y} by myself. Then I should can add the element {x,y,f[x,y]} to a list of computed values of <code>f[x,y]</code> (say "cache") and restart evaluation of <code>ContourPlot</code>. <code>ContourPlot</code> must take all already computed values of <code>f</code> from the cache. I would prefer to store such list in some file for having ability to reuse it later. And it is probably simpler to add problematic points to this file by hand. </p>
  
  <p>What is the fastest way to implement this if the list of computed values of <code>f</code> may contain 10000-50000 points?</p>