Last active
August 1, 2021 10:59
-
-
Save vlaskz/16f175a72443a63a0524e3feb2a1c5f0 to your computer and use it in GitHub Desktop.
Load all keys from a redis DB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment