Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是节点新手。 我需要查询 Mysql 并将该数据同步返回给客户端。 如果我这样做是否意味着即使我使用 evented Mysql lib 我也会阻止 Reactor?我应该如何正确地做到这一点?
我认为那个假的例子会回答你的问题:
var http = require('http'); var db = require('db'); http.createServer(function (req, res) { db.query('fake query', function(data){ res.send(data); } }).listen(1337, '127.0.0.1');
即使您不同步发送响应,也没关系,这就是节点的工作方式。起初我也为这个概念而苦苦挣扎。