Let me put my node.js script bellow.

It failed because probably the redis.disconnect() call finished before redis.set() calls completed.

How can I make redis.disconnet() wait until all "set()" calls has completed?

I need to call redis.disconnect() because I want the script to close on the completion in the terminal. (e.g. node myscript.js -x1)

https://github.com/luin/ioredis

var Redis = require("ioredis");
var redis = new Redis();
for (var i = 0; i < process.argv.length; ++i) {
    var ai = process.argv[i];
   
    if (ai == "-x1") {
        redis.set("x", "1");
        
    }
    if (ai == "-x2") {
        redis.set("x", "2");
        
    }
}
redis.disconnect()

0

There are 0 answers