How to delete the contents of hash table in redis
Editor to share with you how to delete the contents of the hash table in redis. I hope you will gain a lot after reading this article. Let's discuss it together.
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 redis 6379 > HSET myhash field1 "foo" (integer) 1redis 127.0.0.1 1redis 127.0.0.1 1redis 6379 > HDEL myhash field1 (integer) 1redis 127.0.0.1 1redis 6379 > HDEL myhash field2 (integer) 0 after reading this article, I believe you have some understanding of how to delete hash table contents in redis, want to know more about it, welcome to follow the industry information channel, thank you for your reading!