Redis Hash (hash)

Source: Internet
Author: User
Tags redis tutorial

Redis Hash is a string-type field and value mapping table, and hash is particularly useful for storing objects.

Each hash in Redis can store 232-1 key-value pairs (more than 4 billion).

Instance
  1. Redis 127.0. 0.1:6379> hmset w3ckey name "Redis Tutorial" description "Redis basic commands for Cachin G " likes visitors 23000
  2. Ok
  3. Redis 127.0. 0.1:6379> hgetall w3ckey
  4. 1) "name"
  5. 2) "Redis tutorial"
  6. 3) "description"
  7. 4) "Redis basic commands for caching"
  8. 5) "likes"
  9. 6) " the"
  10. 7) "visitors"
  11. 8) "23000"

In the above example, we set up some of the Redis's descriptive information (name, description, likes, visitors) to the w3ckey of the hash table.

Redis Hash Command

The following table lists the basic related commands for Redis hashing:

Serial Number Command and Description
1 Hdel key Field2 [Field2] Delete one or more hash table fields
2 Hexists key field to see if the specified field exists in the hash table key.
3 Hget key field gets the value stored in the specified field in the hash table/td>
4 Hgetall key gets all fields and values that specify key in the hash table
5 Hincrby key field increment adds an incremental increment to the integer value of the specified field in the hash table key.
6 Hincrbyfloat key field increment adds an incremental increment to the floating-point value of the specified field in the hash table key.
7 Hkeys key gets all the fields in the hash table
8 Hlen Key Gets the number of fields in the hash table
9 Hmget key field1 [Field2] Gets the values of all given fields
10 Hmset key field1 value1 [Field2 value2] simultaneously sets multiple field-value (domain-value) pairs to the hash table key.
11 Hset key field value sets the values of the fields in the hash table key to be set to value.
12 Hsetnx key field value sets the values of the hash table field only if the fields field does not exist.
13 Hvals key gets all the values in the hash table
14 The HSCAN key cursor [MATCH pattern] [count count] iterates over the key-value pairs in the hash table.

Redis Hash (hash)

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.