title: nodejs: create same value in a short period
body: <p>I have a sample app, user can access some dynamic data via different URL.</p>
  <p>The workflow is like this:</p>
  <ol>
  <li>when user request <code>get_data?id=1234567</code></li>
  <li>first it checks the DB if there is data for it</li>
  <li>if not, generate a random value</li>
  <li>then if other users request the same url within a short time (say 10 min), it will return the value that already generated</li>
  <li>if one of the users send a clear request, the value will be cleared from DB.</li>
  </ol>
  <p>The bug is: if 2 users request the same url at the same time, since it needs time to query the DB, it would do 1 and 2 at the same time, then create different values for each user.</p>
  <p>How to make sure that in a short period, it always generate same value for all users?</p>