title: Keep order in a key-value use case with additions and deletions
body: <p>I receive big 4 bit hashes list from an API that I need to store.
  The list must always be ordered alphanumerically.</p>
  
  <p>Here's how things are flowing :</p>
  
  <ul>
  <li>I get the full list of hashes from the API (Approx 1,000,000). I store this list.</li>
  <li>I request the API periodically to get a list of additions and deletions to the list.</li>
  </ul>
  
  <hr>
  
  <p>For now I store the hashes list with a 'order' row in a table : </p>
  
  <ul>
  <li><strong>0</strong> - 6717</li>
  <li><strong>1</strong> - 7fcd</li>
  <li><strong>2</strong> - 88c6</li>
  <li><strong>3</strong> - 9e63</li>
  <li><strong>4</strong> - dcb0</li>
  <li><strong>5</strong> - fb44</li>
  </ul>
  
  <p>Now let's say I receive the deletions :</p>
  
  <ul>
  <li><strong>1</strong></li>
  <li><strong>4</strong></li>
  </ul>
  
  <p>And the additions :</p>
  
  <ul>
  <li>7bd7</li>
  <li>0e33</li>
  </ul>
  
  <hr>
  
  <p>I need to delete the rows <strong>1</strong> and <strong>4</strong> :</p>
  
  <ul>
  <li><p><strong>0</strong> - 6717</p></li>
  <li><p><strong>2</strong> - 88c6</p></li>
  <li><p><strong>3</strong> - 9e63</p></li>
  <li><p><strong>5</strong> - fb44</p></li>
  </ul>
  
  <p>And I need to add the additions to the list <em>AND</em> to rebuild the roder row to keep the alphaneumeric order, to be able to to this again :</p>
  
  <ul>
  <li><strong>0</strong> - 0e33</li>
  <li><strong>1</strong> - 6717</li>
  <li><strong>2</strong> - 7bd7</li>
  <li><strong>3</strong> - 88c6</li>
  <li><strong>4</strong> - 9e63</li>
  <li><strong>5</strong> - fb44</li>
  </ul>
  
  <hr>
  
  <p>I need this for a PHP Symfony application, I have implemented this with MySQL but it's pretty slow to create the full list and to rebuild the id row...</p>
  
  <p>As I have a key->value dataset Redis seems to be a good choice but there is no bulk rename function for the keys.</p>
  
  <p>I am also thinking about MongoDB and to create one document for each hash but I'm not really sure.</p>
  
  <p>what would you do ? Thanks</p>