title: Looking for a drop-in replacement for a java.util.Map
body: <h2>Problem</h2>
  
  <p>Following up on <a href="https://stackoverflow.com/questions/4718824/whats-the-right-way-to-integrate-sqlite-with-my-java-ee-app">this question</a>, it seems that a file- or disk-based <code>Map</code> implementation may be the right solution to the problems I mentioned there. Short version:</p>
  
  <ul>
  <li>Right now, I have a <code>Map</code> implemented as a <code>ConcurrentHashMap</code>.</li>
  <li>Entries are added to it continually, at a fairly fixed rate. Details on this later.</li>
  <li>Eventually, no matter what, this means the JVM runs out of heap space.</li>
  </ul>
  
  <p>At work, it was (strongly) suggested that I solve this problem using SQLite, but after asking that previous question, I don't think that a database is the right tool for this job. So - <strong>let me know if this sounds crazy</strong> - I think a better solution would be a <code>Map</code> stored on disk.</p>
  
  <p>Bad idea: implement this myself. Better idea: use someone else's library! <strong>Which one?</strong></p>
  
  <h2>Requirements</h2>
  
  <h3>Must-haves:</h3>
  
  <ul>
  <li><strong>Free.</strong></li>
  <li><strong>Persistent.</strong> The data needs to stick around between JVM restarts.</li>
  <li>Some sort of <strong>searchability.</strong> Yes, I need the ability to retrieve this darn data as well as put it away. Basic result set filtering is a plus.</li>
  <li><strong>Platform-independent.</strong> Needs to be production-deployable on Windows or Linux machines.</li>
  <li><strong>Purgeable</strong>. Disk space is finite, just like heap space. I need to get rid of entries that are <code>n</code> days old. It's not a big deal if I have to do this manually.</li>
  </ul>
  
  <h3>Nice-to-haves:</h3>
  
  <ul>
  <li><strong>Easy to use.</strong> It would be great if I could get this working by the end of the week.<br>
  Better still: the end of the day. It would be <em>really, really</em> great if I could add one JAR to my classpath, change <code>new ConcurrentHashMap&lt;Foo, Bar&gt;();</code> to <code>new SomeDiskStoredMap&lt;Foo, Bar&gt;();</code><br>
  and be done.</li>
  <li>Decent <strong>scalability and performance.</strong> Worst case: new entries are added (on average) 3 times per second, every second, all day long, every day. However, inserts won't always happen that smoothly. It might be <code>(no inserts for an hour)</code> then <code>(insert 10,000 objects at once)</code>.</li>
  </ul>
  
  <h2>Possible Solutions</h2>
  
  <ul>
  <li><a href="http://ehcache.org/" rel="nofollow noreferrer">Ehcache</a>? I've never used it before. It was a <a href="https://stackoverflow.com/questions/4718824/whats-the-right-way-to-integrate-sqlite-with-my-java-ee-app/4719958#4719958">suggested solution</a> to my previous question.</li>
  <li><a href="http://www.oracle.com/technetwork/database/berkeleydb/overview/index.html" rel="nofollow noreferrer">Berkeley DB</a>? Again, I've never used it, and I really don't know anything about it.</li>
  <li><a href="http://hadoop.apache.org/" rel="nofollow noreferrer">Hadoop</a> (and which subproject)? Haven't used it. Based on <a href="http://hadoop.apache.org/common/docs/current/single_node_setup.html" rel="nofollow noreferrer">these docs</a>, its cross-platform-readiness is ambiguous to me. I don't need distributed operation in the foreseeable future.</li>
  <li>A <a href="http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC" rel="nofollow noreferrer">SQLite JDBC driver</a> after all?</li>
  <li><strong>???</strong></li>
  </ul>
  
  <p>Ehcache and Berkeley DB both look reasonable right now. Any particular recommendations in either direction?</p>