title: Fast embedded database
body: <p>I am working on an application which will need to store metadata associated with music files (artist, title, play count, etc.), as well as sets of integers (in particular, SHA-1 hashes).</p>
  
  <p>The solution I pick needs to:</p>
  
  <ul>
  <li>Provide "fast" storage &amp; retrieval (when viewing a list of potentially thousands of songs I need to be able to retrieve metadata more or less interactively).</li>
  <li>Be cross-platform (to Linux, Windows and OSX).</li>
  <li>Provide an interface I can interact with from C++.</li>
  <li>Be open-source (or, at the very least, be free as in beer).</li>
  <li>Provide fast set operations (union, intersection, difference) - if the solution doesn't provide this, but it will allow me to store binary data, I could implement this myself using a technique like <a href="http://www.cs.cmu.edu/~scandal/treaps.html" rel="noreferrer">"Fast Set Operations Using Treaps"</a>.</li>
  <li>Be "embedded" - that is, operate without me having to <code>fork</code> another process, or at least provide an easy interface to do so (like libmysqld).</li>
  </ul>
  
  <p>Solutions I have considered include:</p>
  
  <ul>
  <li>Flat files. This is extremely simple, but doesn't provide any features besides flat data storage.</li>
  <li>SQlite. This seems to be a very popular option, but it seems to have some issues regarding performance and concurrency (see <a href="https://techbase.kde.org/Projects/PIM/Akonadi/Database#Sqlite" rel="noreferrer">KDE's Akonadi</a>, for some example issues).</li>
  <li>Embedded MySQL/MariaDB. This seems to be a reasonable option, but it also might be a bit heavyweight considering I won't be needing a lot of complicated SQL features.</li>
  </ul>
  
  <p>A hypothetical solution I'm thinking would be perfect would be something like Redis, but which persists data to the disk, and only stores some portion of the data in memory to make retrieval fast. Redis itself might not be a good option because 1) I would need to <code>fork</code> it manually, 2) its Windows port seems less than rock-solid, and 3) storing <strong>all</strong> of my data in RAM would be less than ideal.</p>
  
  <p>Are there any other solutions for this type of problem, or is one of the solutions I have already listed far better than the others?</p>