Redis Hash: HDEL
HDEL key field2 [field2]
Redis HDEL command is used to remove the specified fields from the hash stored at a key and ignored the specified keys that do not exist within this hash. It is treated as an empty hash if the key does not exist, and this command returns 0.
Syntax:
HDEL KEY_NAME FIELD1.. FIELDN
Available since
2.0.0.
Return Value
Integer reply, the number of fields that were removed from the hash, not including specified but non-existing fields.
Return Value Type
Integer
Example: Redis HDEL
127.0.0.1:6379> HMSET langhash lang1 "PHP" lang2 "JavaScript" lang3 "Python" OK 127.0.0.1:6379> HGET langhash lang1 "PHP" 127.0.0.1:6379> HGET langhash lang2 "JavaScript" 127.0.0.1:6379> HGET langhash lang3 "Python" 127.0.0.1:6379> HDEL langhash lang1 (integer) 1 127.0.0.1:6379> HGET langhash lang1 (nil) 127.0.0.1:6379> HGET langhash lang2 "JavaScript" 127.0.0.1:6379> HGET langhash lang3 "Python"
Example: Redis Remove multiple fields
127.0.0.1:6379> HMSET langhash lang1 "PHP" lang2 "JavaScript" lang3 "Python" OK 127.0.0.1:6379> HGET langhash lang1 "PHP" 127.0.0.1:6379> HGET langhash lang2 "JavaScript" 127.0.0.1:6379> HGET langhash lang3 "Python" 127.0.0.1:6379> HDEL langhash lang1 lang2 lang3 (integer) 3 127.0.0.1:6379> HGET langhash lang1 (nil) 127.0.0.1:6379> HGET langhash lang2 (nil) 127.0.0.1:6379> HGET langhash lang3 (nil)
Example: Redis HDEL another example
127.0.0.1:6379> HGETALL user 1) "email" 2) "[email protected]" 3) "lang" 4) "English" 5) "gender" 6) "Male" 127.0.0.1:6379> HDEL user email (integer) 1 127.0.0.1:6379> HDEL user lang gender (integer) 2
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework