最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Redis - How to list all keys in database? - Stack Overflow

programmeradmin2浏览0评论

I start playing with Redis, put some values into database.

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();
});

How to list all keys in database?

or is there free GUI (Redsmin / is free only while beta)

I start playing with Redis, put some values into database.

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();
});

How to list all keys in database?

or is there free GUI (Redsmin https://redsmin./ is free only while beta)

Share Improve this question asked Oct 14, 2013 at 7:23 Paul VerestPaul Verest 64.1k53 gold badges225 silver badges353 bronze badges 2
  • Looks like you're looking for keys mand. – Leonid Beschastny Commented Oct 14, 2013 at 7:47
  • 1 Hello Paul, founder of Redsmin there, just to confirm that there will always be a free plan in Redsmin because we want to give back to the awesome Redis munity :) – FGRibreau Commented Oct 15, 2013 at 9:01
Add a ment  | 

2 Answers 2

Reset to default 6

Use keys method with pattern *

According to the docs

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

This works, but as written in the docs

Warning: consider KEYS as a mand that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This mand is intended for debugging and special operations, such as changing your keyspace layout. Don't use KEYS in your regular application code. If you're looking for a way to find keys in a subset of your keyspace, consider using SCAN or sets.

Therefore until you work on a local project KEY mand is fine, but avoid using it on production.

If you want a Redis GUI, you can have a look at Redis Desktop. I work with it and it is very useful.

发布评论

评论列表(0)

  1. 暂无评论