const PORT = //put the port number. 6379 by default const HOST = //host addres const PWD = //password const DB = //db instance to connect, it varies from 0-15 var rds = require("redis"); //client retornado. conexão se for usar ssl, se não, não precisa usar tls. var cli = rds.createClient(PORT, HOST, { auth_pass: PWD, tls: { servername: HOST } }); var fs = require("fs"); let keys = null; cli.on('connect', (err, res) => { cli.select(DB, () => { if (err) throw err; console.log('INFO:: DB ', DB, ' selected.') }) cli.KEYS("*", (err, reply) => { if (err) throw err; keys = reply; keys = JSON.stringify(keys); fs.writeFile("keys.json", keys, () => { console.log("Done!") }); console.log(reply.length); cli.quit(); }); });