admin管理员组

文章数量:1355111

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.

本文标签: javascriptRedisHow to list all keys in databaseStack Overflow