[redis] 獲得 database, key, value

來源:互聯網
上載者:User

標籤:

獲得 database

The INFO KEYSPACE command can be used to check whether some keys are 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 be 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"
擷取所有的 key

keys **是萬用字元

http://redis.io/commands/keyshttp://redis.io/commands/keys

擷取 key 的 value

因為 redis 有多種資料類型,並且每種類型的取值方法不同,所有首先需要知道 key 儲存的 value 類型

You will need to perform for each key a type and depending on the 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 that for hashes and sorted sets you will be getting the keys/scores and values.

[redis] 獲得 database, key, value

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.