Redis Hash操作

來源:互聯網
上載者:User

標籤:

Redis Hash操作

1、HSET key field value

  Sets field in the hash stored at key to value. If key does not exist, a new key holding a hash is created. If field already exists in the hash, it is overwritten.

Return value

Integer reply, specifically:

  • 1 if field is a new field in the hash and value was set.
  • 0 if field already exists in the hash and the value was updated.

  

2、HEXISTS key field

  Returns if field is an existing field in the hash stored at key.

Return value

Integer reply, specifically:

  • 1 if the hash contains field.
  • 0 if the hash does not contain field, or key does not exist.

  

3、HGET key field

  Returns the value associated with field in the hash stored at key.

Return value

Bulk string reply: the value associated with field, or nil when field is not present in the hash or key does not exist.

  

4、HDEL key field [field ...]

  Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored. If key does not exist, it is treated as an empty hash and this command returns 0.

Return value

Integer reply: the number of fields that were removed from the hash, not including specified but non existing fields.

5、HKEYS key

  Returns all field names in the hash stored at key.

Return value

Array reply: list of fields in the hash, or an empty list when key does not exist.

  

6、HVALS key

  Returns all values in the hash stored at key.

Return value

Array reply: list of values in the hash, or an empty list when key does not exist.

  

7、HGETALL key

  Returns all fields and values of the hash stored at key. In the returned value, every field name is followed by its value, so the length of the reply is twice the size of the hash.

Return value

Array reply: list of fields and their values stored in the hash, or an empty list when key does not exist.

  

8、HLEN key

  Returns the number of fields contained in the hash stored at key.

Return value

Integer reply: number of fields in the hash, or 0 when key does not exist.

  

9、HMSET key field value [field value ...]

  Sets the specified fields to their respective values in the hash stored at key. This command overwrites any existing fields in the hash. If key does not exist, a new key holding a hash is created.

 

Redis Hash操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.