title: NodeJS: process.nextTick vs Instant Callbacking
body: <p>I write lots of modules which look like this:</p>
  
  <pre><code>function get(index, callback) {
      if (cache[index] === null) {
          request(index, callback); // Queries database to get data.
      } else {
          callback(cache[index]);
      }
  }
  </code></pre>
  
  <p><em>Note: it's a bit simplified version of my actual code.</em></p>
  
  <p>That callback is either called in the same execution or some time later. This means users of the module aren't sure which code is run first.</p>
  
  <p>My observation is that such module reintroduces some problems of the multi-threading which was previously solved by JavaScript engine.</p>
  
  <p>Question: should I use <code>process.nextTick</code> or ensure it's safe for the callback to be called outside the module?</p>