var proxy = new EventProxy();
var status = "ready";
var select = function(callback){
proxy.once("selected",callback);
if(status == "ready"){
status = "pending";
db.select("SQL", function(results){
proxy.emit("selected",results);
status = "ready";
});
}


网上摘的,看得懂么。短短几行代码。功效 perfect!
在一条sql执行的时间内,如果来了1000条访问请求,那么一次查询结果将返回给1000条请求,node.js 高并发可见一斑。

 

相关参考资料
http://blog.csdn.net/aoyzc/article/details/8272162
http://www.infoq.com/cn/articles/tyq-nodejs-event

相关文章:

  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2021-12-10
  • 2021-05-01
  • 2021-09-24
  • 2021-12-25
  • 2021-10-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-07-10
  • 2022-03-08
  • 2021-08-07
  • 2021-10-28
相关资源
相似解决方案