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
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join