title: Should one use redis to generate auto incrementing values?
body: <p>I am designing an application that uses MongoDB for storage. As you probably know the ObjectId datatype that mongo provides is a 12 byte hexadecimal. I would like to show my users a more user friendly id instead.</p>
  
  <p>I looked into several options like PHP's uniqid() and several variations thereof but I don't trust them because of the collisions the randomness entails (see <a href="http://en.wikipedia.org/wiki/Birthday_problem#Probability_table" rel="nofollow">Birthday Problem</a>).</p>
  
  <p>Redis looks really attractive to me for this kind of operation (see <a href="http://redis.io/commands/incr" rel="nofollow">INCR</a>). This requires the web application to call redis every time it needs to create new record. I will only need about 15-20 counters inside redis which will have a tiny footprint so replication will never become an issue. Also the app can connect to it using a socket to avoid the tcp overhead.</p>
  
  <p>Am I thinking about it the wrong way? Is there something else I should consider?</p>
  
  <p>Thanks,
  Alex</p>