Home > Database > Redis > body text

How to delete the contents of hash table in redis

Release: 2019-07-04 16:28:27
Original
8178 people have browsed it

How to delete the contents of hash table in redis

hash:

Redis hash is a mapping table of string type fields and values. Hash is particularly suitable 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" likes 20
 visitors 23000
OK
127.0.0.1:6379>  HGETALL runoobkey
1) "name"
2) "redis tutorial"
3) "description"
4) "redis basic commands for caching"
5) "likes"
6) "20"
7) "visitors"
8) "23000"
Copy after login

Delete command:

Hdel command

The Redis Hdel command is used to delete one or more keys in the hash table specified fields, non-existing fields will be ignored.

The basic syntax of the redis Hdel command is as follows:

redis 127.0.0.1:6379> HDEL KEY_NAME FIELD1.. FIELDN
Copy after login

Return value:

The number of successfully deleted fields, excluding ignored fields.

redis 127.0.0.1:6379> HSET myhash field1 "foo"
(integer) 1
redis 127.0.0.1:6379> HDEL myhash field1
(integer) 1
redis 127.0.0.1:6379> HDEL myhash field2
(integer) 0
Copy after login

For more Redis related knowledge, please visit the Redis usage tutorial column!

The above is the detailed content of How to delete the contents of hash table in redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template