I use redis client in node.js
var db = require("redis");
var dbclient = db.createClient();
I load the DB in the next way:
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)
}
})
I notice that where my application is started, it takes 30~ sec. for the DB query to execute. In this time, no other request from Express
module are served.
How can I slove this issue? Why is no a asynchronous?
loop for
- no. – stdob-- Sep 5 at 11:06replies.length
? – robertklep Sep 5 at 11:38