Recall & Review
beginner
What does the Redis command
HLEN do?It returns the number of fields stored in a hash stored at a given key.
Click to reveal answer
beginner
How do you use
HLEN to count fields in a hash named user:1000?You run
HLEN user:1000. It returns the count of fields inside that hash.Click to reveal answer
beginner
What type of data structure must the key hold for
HLEN to work?The key must hold a hash data structure in Redis.
Click to reveal answer
beginner
What happens if you use
HLEN on a key that does not exist?Redis returns 0 because there are no fields in a non-existing hash.
Click to reveal answer
beginner
Can
HLEN be used on other Redis data types like strings or lists?No,
HLEN only works on hashes. Using it on other types returns a type error.Click to reveal answer
What does the Redis command
HLEN myhash return?✗ Incorrect
HLEN returns the count of fields in a hash stored at the given key.
If the key 'profile' does not exist, what does
HLEN profile return?✗ Incorrect
Redis returns 0 for HLEN on a non-existing hash key.
Which Redis data type is required for
HLEN to work correctly?✗ Incorrect
HLEN works only on hashes.
What happens if you run
HLEN on a key holding a string?✗ Incorrect
Using HLEN on non-hash types causes a type error.
Which command would you use to find how many fields are in a Redis hash?
✗ Incorrect
HLEN returns the number of fields in a hash.
Explain what the Redis command
HLEN does and when you would use it.Think about how you count items in a collection.
You got /3 concepts.
Describe what happens if you run
HLEN on a key that holds a string instead of a hash.Consider data types and command compatibility.
You got /3 concepts.