Get database
The INFO KEYSPACE
command can used to check whether some keys is defined in several databases.
redis 127.0.0.1:6379[1]> info keyspace# Keyspacedb0:keys=1,expires=0db1:keys=1,expires=0
The SELECT
command can used to switch a session to another database. The SELECT command can be used to switch a session to another database.
redis 127.0.0.1:6379> select 1OKredis 127.0.0.1:6379[1]> keys *1) "bar"
Get all the keys
keys *
, *
is a wildcard character
Http://redis.io/commands/keyshttp://redis.io/commands/keys
Get the value of key
Because Redis has a variety of data types, and each type of method differs, all you need to know is the value type stored by key first
You'll need to perform for each key A and depending on the type
response perform:
- For "string": Get
- For "Hash": Hgetall
- For "list": Lrange 0-1
- For "Set": Smembers
- For "Zset": Zrange 0-1 Withscores
Keep in mind, hashes and sorted sets you'll be getting the keys/scores and values.
[Redis] Get database, key, value