================================== Two types: hash type ============================
Description: redis-> hash is a string type field and value ing table.
Hash is especially suitable for storing objects. It stores each field of an object as a single string type.
Storing an object in the hash type consumes less memory and can easily access the entire object.
0: hset * If the key (that is, the hash table) does not exist, a new hash table is created and hset is performed.
Set hash field to the specified value. If the key does not exist, create
Example: hset User: 001 name leyangjun creates a table
0.2: hsetnx
Set hash field to the specified value. If the value does not exist, create the value. If the value exists, 0 is returned.
Example: hsetnx User: 002 name leyangjun
1: hmset: Set the Field Values of multiple hash tables
Set multiple hash fields at the same time
Example: hmset user003 name leyangjun age 23 sex 1 --> hash table 003 value set successfully
Hget get: hget User: 003 name --> get the 003 name value of the hash table
2: hget
Obtains the specified hash field value.
Example: hget user003 name --> indicates the field
3: hmet
Obtains all specified hash fields.
Example: hmet User: 003 name age sex
4: hincrby)
Add a specified value to the specified hash Field
Example: hincrby User: 003 age 5 --> Add 5 20 + 5 to the original age value
5: hexists
Test whether the specified field exists.
Example: hexists User: 003 sex --> judge whether the hash table field exists
6: hlen
Returns the number of all fields in the specified hash table.
Example: hlen user003
7: hdel
Deletes the field value in the specified hash table.
Example: hdel user003 age --> Delete the age field in user003
8: hkeys
Returns all fields in the hash table.
Example: hkeys user003
9: hvals
Returns all values of the hash table.
Example: hvals user003 --> values of keys in all tables
10: * Common hgetall
Obtains all fields and values in a hash.
Example: hgetall user003
========================================================== = End ============================================== =
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.