Redis Hash Operations

Source: Internet
Author: User

"Redis hash Operation "

1.hset key field value

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

Return value

Integer reply, specifically:

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

  

2.hexists key field

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

Return value

Integer reply, specifically:

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

  

3.hget key field

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

Return value

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

  

4.Hdel key field [field ...]

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

Return value

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

5.Hkeys Key

  Returns all field names in the hash stored 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 key .

Return value

Array reply:list of values in the hash, or a 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 was followed by it 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 a 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 In the 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 the hash. If key does not exist, a new key holding a hash is created.

Redis Hash Operations

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.