In Redis, the hash data type stores data in a very similar way to storing a record in a MySQL database, a string-type field and value mapping table, which is particularly well-suited for storing objects, but the field values can only be strings and no other types are supported.
In the hash type, a key can correspond to more than one field, and a field corresponds to a value. One of the benefits of storing an object as a hash type is that it can save memory more than if each field is stored separately as a string type.
Here is a hash (hash) Type of common Operations Command:
1. "Hset key field value" Sets the hash field to the specified value, and if key does not exist, it is created first.
2. "Hmset key field1 value1 ... fieldn valuen" sets multiple values at the same time.
3. "Hget key field" Gets the specified hash field
4. "Hmget key field1 field1 ... fieldn" gets the specified multiple hash field
5. "Hincrby key field num" adds the specified hash field to the specified value.
6. "Hexists key field" To see if the specified field exists.
7. "Hdel key Field" Deletes the specified hash field.
8. "Hlen Key" returns the number of field in the specified hash.
9. "Hkeys key" returns the hash of all field.
10. "Hvals" returns all the value in the hash.
11. "Hgetall Key" returns all field and value in the hash.
Each hash can store more than 2 of 32 square-1 field-value pairs. Application scenario: can be used to store the user's basic information, and so on.