You can simply pass the array as follows
var redis = require("redis"), client = redis.createClient(); client.on("error", function (err) { console.log("Error " + err); }); client.set("aaa", "aaa"); client.set("bbb", "bbb"); client.set("ccc", "ccc"); var keys = ["aaa", "bbb", "ccc"]; client.keys("*", function (err, keys) { keys.forEach(function (key, pos) { console.log(key); }); }); client.del(keys, function(err, o) { }); client.keys("*", function (err, keys) { keys.forEach(function (key, pos) { console.log(key); }); });
If you run the above code, you will get the following output
$ node index.js string key hash key aaa ccc bbb string key hash key
showing keys printed after installation but not printed after removal
source share