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"
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
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
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!