Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

求教process.nextTick() 的使用场景?

$
0
0
exports.findByUsername = function(username, cb) {
  process.nextTick(function() {
    for (var i = 0, len = records.length; i < len; i++) {
      var record = records[i];
      if (record.username === username) {
        return cb(null, record);
      }
    }
    return cb(null, null);
  });
}

是不是在处理数据库等耗时操作时,使用process.nextTick() ,可以提高系统的并发量


Viewing all articles
Browse latest Browse all 14821

Trending Articles