Node.js中对continuation-local-storage模块的并发请求

时间:2015-03-13 13:08:18

标签: javascript node.js express

我使用Node js continuation-local-storage来存储每个请求的唯一ID

app.use(function(req, res, next) {
   var tid = uuid.v4();
   var pre_ip;
      if(get_ip(req))
      { ip_info= get_ip(req).clientIp;
          pre_ip=ip_info
      }
      namespace.bindEmitter(req);
      namespace.bindEmitter(res);
    namespace.run(function() {
           console.log(logobj);
          namespace.set('tid', tid);
          namespace.set('ip',ip_info);
       namespace.set('logobj',logobj);   
          next();
      });
  });

但如果并发请求到来,它就能向我显示正确的tid。如果是,那么如何。

0 个答案:

没有答案