【发布时间】:2015-12-01 09:53:34
【问题描述】:
我在node.js中使用redis客户端
var db = require("redis");
var dbclient = db.createClient();
我用下一种方式加载数据库:
dbclient.zrange("cache", -1000000000000000, +1000000000000000, function(err, replies){
logger.info("Go to cache");
for (var i=0; i < replies.length; i++){
(function(i){
// Do some commands with the result
})(i)
}
})
我注意到我的应用程序从哪里开始,需要 30~ 秒。用于执行数据库查询。此时,不会处理来自Express 模块的其他请求。
我该如何解决这个问题?为什么没有异步?
【问题讨论】:
-
redis的异步API。但是
loop for- 没有。 -
什么是"do some commands with the result"?
replies.length是什么?
标签: node.js asynchronous redis