Redis data Type--hash (hashes)

Source: Internet
Author: User

1. Hashing Hash

  

Summary: Redis Hash is a string-type field and value mapping table. It is 0 (1) (average) to add and delete operations.


Hash is particularly useful for storing objects. is equivalent to saving each field of an object into a single string type.

storing an object in a hash type consumes less memory and makes it easier to access the entire object, saving memory because a new hash object is initially stored with Zipmap.

  

Method:

1. Hset sets the hash field to the specified value, and if key does not exist, it is created first. such as Hset users:001 name test001

2. Hsetnx sets the hash field to the specified value, and if key does not exist, it is created first. If field already exists, returning 0,nx is the meaning of not exist.

3. Hmset also set multiple fields for hash. Hmset user:001 name test001 age 20

4. Hget Gets the specified hash field, no time returns nil Hget user:001 name

5. Hmget get all specified hash field (if that filed not, return nil) hmget user:001 name Age

6. Hincrby The specified hash filed plus the given value Hincrby user:001 age-8 (positive increment minus)

7. Hexists test Specifies whether field exists to return 1, does not exist return 0 hexists user:001 name

8. Hlen returns the field number of the specified hash Hlen user:001 returns 2 has 2 columns

9. Hdel Delete a field Hdel user:001 name in the hash

Hkeys return hash of all field Hkeys user:001

Hvals returns all the value in the hash

Hgetall returns all field and value in the hash

Http://bbs.lampbrother.net/read-htm-tid-131711-ds-1.html

Redis data Type--hash (hashes)

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.