Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the reidis hash type hash

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how to use reidis hash type hash". In daily operation, I believe many people have doubts about how to use reidis hash type hash. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use reidis hash type hash"! Next, please follow the editor to study!

Redis's hash is a mapping table of key and value of type string, where value is a series of key-value pairs, and hash is particularly suitable for storing objects. The general idea of hash-type data operations is to operate through key and field value,key is the data identity, field is the domain, and value is the business data. Hset

Syntax: hset key field value [field value...]

Function: set the key value pair field-value to the hash list key, if the key does not exist, create a new hash list, and then perform the assignment. If the field under key already exists, the value is overwritten.

Return value: returns the number of key-value pairs successfully set.

Hget

Syntax: hget key field

Function: gets the value of the given field field in the hash table key.

Return value: the value of the field field, which returns nil if key does not exist or field does not exist.

Hgetall

Syntax: hgetall key

Function: get all the fields and values in the hash table key

Return value: returns the values of fields and fields in hash in the form of a list. Key does not exist and returns empty hash.

Hdel

Syntax: hdel key field [field...]

Function: delete one or more specified domain field in the hash table key, and no field directly ignores it.

Return value: the number of field successfully deleted.

Hlen

Syntax: hlen key

Function: get the number of domain field in the hash table key

Return value: numeric value, number of field. Key does not exist and returns 0.

Hexists

Syntax: hexists key field

Function: check whether the given domain field exists in the hash table key

Return value: if field exists, it returns 1, and the other returns 0.

Hkeys

Syntax: hkeys key

Function: view a list of all field fields in the hash table key

Return value: contains a list of all field. There is no empty list returned for key.

Hvals

Syntax: hvals key

Function: returns a list of values for all fields in the hash table

Return value: contains a list of all field values in the hash table. There is no empty list returned in key.

Hsetnx

Syntax: hsetnx key field value

Function: set the value of the field field in the hash table key to value, and set it only if the domain field does not exist, otherwise it will not be set.

Return value: if the value is successful, it returns 1, and the other returns 0.

At this point, the study on "how to use the reidis hash type hash" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report