Redis的 – 如何列出数据库中的所有键?

我开始玩Redis,把一些值放到数据库中。

var redis = require("redis"), client = redis.createClient(); // if you'd like to select database 3, instead of 0 (default), call // client.select(3, function() { /* ... */ }); client.on("error", function (err) { console.log("Error " + err); }); client.set("string key", "string val", redis.print); client.hset("hash key", "hashtest 1", "some value", redis.print); client.hset(["hash key", "hashtest 2", "some other value"], redis.print); client.hkeys("hash key", function (err, replies) { console.log(replies.length + " replies:"); replies.forEach(function (reply, i) { console.log(" " + i + ": " + reply); }); client.quit(); }); 

如何列出数据库中的所有密钥?

还是有免费的graphics用户界面(Redsmin的https://redsmin.com/是免费的,而只有testing版)

使用键盘模式*

根据文件

 redis> MSET one 1 two 2 three 3 four 4 OK redis> KEYS ** 1) "one" 2) "two" 3) "three" 3) "four" 

这工作,但正如在文档中写的

警告:将KEYS看作只能在生产环境中谨慎使用的命令。 对大型数据库执行操作可能会导致性能下降。 此命令用于debugging和特殊操作,例如更改您的键盘空间布局。 不要在您的常规应用程序代码中使用KEYS。 如果您正在寻找一种方法在您的密钥空间的子集中查找密钥,请考虑使用SCAN或集合。

因此,直到您处理本地项目的KEY命令为止,但是请避免在生产环境中使用它。

如果你想要一个Redis GUI ,你可以看看Redis Desktop 。 我与它合作,这是非常有用的。