[Redis] Get database, key, value

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.