title: Disk backed dictionary/cache for c#
body: <p>I'm looking for a drop in solution for caching large-ish amounts of data.</p>
  
  <p>related questions but for different languages:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/226693/python-disk-based-dictionary">Python Disk-Based Dictionary</a></li>
  <li><a href="https://stackoverflow.com/questions/149488/disk-backed-stl-container-classes">Disk-backed STL container classes?</a></li>
  </ul>
  
  <p>Close question in different terms:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/100235/looking-for-a-simple-standalone-persistant-dictionary-implementation-in-c">Looking for a simple standalone persistant dictionary implementation in C#</a></li>
  </ul>
  
  <p>I don't need (or want to pay anything for) persistence, transactions, thread safety or the like and want something that is not much more complex to use than a List&lt;> or Dictionary&lt;>.</p>
  
  <p>If I have to write code, I'll just save everything off as files in the temp directory:</p>
  
  <pre><code>string Get(int i)
  {
     File.ReadAllText(Path.Combine(root,i.ToString());
  }
  </code></pre>
  
  <p>In my cases in index will be an <code>int</code> (and they should be consecutive or close enough) and the data will be a <code>string</code> so I can get away with treating both a <a href="http://en.wikipedia.org/wiki/Plain_Old_Data_Structures" rel="nofollow noreferrer">POD</a> and would rather go ultra-light and do exactly that.</p>
  
  <p>The usage is that I have a sequence of 3k files (as in file #1 to #3000) totaling 650MB and need to do a diff for each step in the sequence. I expect that to total about the same or a little more and I don't want to keep all that in memory (larger cases may come along where I just can't).</p>
  
  <hr>
  
  <p>A number of people have suggested different solutions for my problem. However none seem to be targeted at my little niche. The reasons that I'm looking at disk backed caching is because I'm expecting that my current use will use up 1/3 to 1/2 of my available address space. I'm worried that larger cases will just flat run out of space. I'm not worried about treading, persistence or replication. What I'm looking for is a minimal solution using a minimum of code, a minimal usage foot print, minimal in memory overhead and minimum complexity.</p>
  
  <p>I'm starting to think I'm being overly optimistic.  </p>