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 implement the contents of hash table in redis

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about how to achieve hash table in redis, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Hash:

Redis hash is a mapping table for field and value of type string, and hash is particularly suitable for storing objects.

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

Example:

127.0.1 HMSET runoobkey name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000OK127.0.0.1:6379 > HGETALL runoobkey1) "name" 2) "redis tutorial" 3) "description" 4) "redis basic commands for caching" 5) "likes" 6) "20" 7) "visitors" 8) "23000"

Delete command:

Hdel command

The Redis Hdel command is used to delete one or more specified fields in the hash table key, and fields that do not exist are ignored.

The basic syntax for redis Hdel commands is as follows:

Redis 127.0.0.1 6379 > HDEL KEY_NAME FIELD1.. FIELDN

Return value:

The number of fields that were successfully deleted, excluding fields that were ignored.

Redis 127.0.0.1 1redis 6379 > HSET myhash field1 "foo" (integer) 1redis 127.0.0.1 1redis 6379 > HDEL myhash field1 (integer) 1redis 127.0.0.1 foo 6379 > HDEL myhash field2 (integer) 0

Content extension:

The Redis Hdel command is used to delete one or more specified fields in the hash table key, and fields that do not exist are ignored.

Grammar

The basic syntax for redis Hdel commands is as follows:

Redis 127.0.0.1 6379 > HDEL KEY_NAME FIELD1.. FIELDN

Available version

> = 2.0.0

Return value

The number of fields that were successfully deleted, excluding fields that were ignored.

Example

Redis 127.0.0.1 1redis 6379 > HSET myhash field1 "foo" (integer) 1redis 127.0.0.1 1redis 6379 > HDEL myhash field1 (integer) 1redis 127.0.0.1 1redis 6379 > HDEL myhash field2 (integer) 0 is how to implement the contents of the hash table in redis. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Database

Wechat

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

12
Report