Redis Hash (hash)

Source: Internet
Author: User
Tags redis tutorial

Redis Hash (hash)

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
127.0.0.1:6379>Hmset Runoobkey Name"Redis Tutorial"Description"Redis basic commands for caching"Likes20Visitors23000Ok127.0.0.1:6379>Hgetall Runoobkey1) "Name"2)   "Redis Tutorial" Span class= "PLN" >3)   "description" 4)   "Redis basic commands for Caching "5)  " likes " Span class= "PLN" >6)   "20" 7)   "visitors" 8)   "23000"    

In the above example, we set up some of the Redis's descriptive information (name, description, likes, visitors) to the Runoobkey 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
Look at the hash table key, the specified field exists.
3 Hget key Field
Gets the value that is stored in the specified field in the hash table.
4 Hgetall Key
Get 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 the fields from all the hash tables
8 Hlen Key
Gets the number of fields in the hash table
9 Hmget key field1 [Field2]
Gets the value of all given fields
10 Hmset key field1 value1 [Field2 value2]
Set multiple Field-value (domain-value) pairs to the hash table key at the same time.
11 Hset key field value
Set the value of the field in the hash table key to values.
12 Hsetnx key field value
Sets the value of the hash table field only if the field does not exist.
13 Hvals Key
Get all values in the hash table
14 HSCAN key cursor [MATCH pattern] [count Count]
Iterates over key-value pairs in a 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.