/ Published in: JavaScript
Delete all your Redis keys with nodejs, through the CLI.
Expand |
Embed | Plain Text
/* By. Alejandro Morales @_alejandromg El Siguiente script elimina todas las 'Keys' de una BDD Redis Peligrosa en las manos equivocadas. ��til? Si. */ process.stdin.resume(); process.stdin.setEncoding('utf8'); console.log('\x1B[1;33m�¿Borrar? (Y/n)\x1B[0m '); function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } process.stdin.on('data', function (chunk) { chunk = trim(chunk); if (chunk == "Y") { var client = require("redis").createClient(); client.keys("*", function (err, keys) { keys.forEach(function (key, pos) { client.del(key, function(err, o) { if (err) { console.error('No se elimino: ' + key); } else { console.log('Se borro: ' + key); } if (pos === (keys.length - 1)) { client.quit(); } }); }); }); } else { console.log('No v�¡lido. Saliendo\n'); } process.kill(process.pid, 'SIGHUP'); });
You need to login to post a comment.
