Redis HDEL – How to delete a field from the hash value in redis datastore
2 months ago Lalit Bhagtani 0
In this tutorial, we will learn about how to delete one or more fields from the hash value stored at a key. For this we will use a COMMAND – HDEL in redis-cli.
This command, removes one or more specified fields from the hash value stored at the key. Specified fields that are not present in the hash value are ignored.
0 is returned, if key does not exist as it is considered as an empty hash value. Error is returned, if key exist but value stored at the key is not of hash datatype. The syntax of redis HDEL command is as follows :-
redis host:post> HDEL <keyname> <element> [ element ]
- (integer) representing number of fields deleted from the hash, excluding non existing fields. - Error, if key exist and value stored at the key is not a hash.
That’s all for how to delete one or more fields from the hash value stored in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.