Challenge - 5 Problems
Redis SMEMBERS Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
What is the output of SMEMBERS command?
Given a Redis set stored with key fruits containing
apple, banana, and cherry, what will the command SMEMBERS fruits return?Redis
SMEMBERS fruits
Attempts:
2 left
💡 Hint
SMEMBERS returns all members of the set stored at the key.
✗ Incorrect
SMEMBERS returns all elements in the set stored at the given key. Since the set contains apple, banana, and cherry, all three are returned.
🧠 Conceptual
intermediate1:00remaining
What type of data structure does SMEMBERS work on?
The Redis command
SMEMBERS is used to list all elements of which Redis data type?Attempts:
2 left
💡 Hint
SMEMBERS is related to a collection of unique elements.
✗ Incorrect
SMEMBERS works on Redis sets, which are unordered collections of unique strings.
📝 Syntax
advanced1:30remaining
Which command syntax correctly lists all members of a set named 'colors'?
Choose the correct Redis command to list all members of the set stored under the key
colors.Attempts:
2 left
💡 Hint
The command starts with 'S' and lists members of a set.
✗ Incorrect
SMEMBERS is the correct command to get all members of a set. SGET and GET are invalid for sets, and HGETALL is for hashes.
❓ query_result
advanced1:30remaining
What happens if SMEMBERS is run on a non-existent key?
If you run
SMEMBERS unknown_key where unknown_key does not exist in Redis, what is the output?Attempts:
2 left
💡 Hint
Redis returns empty collections for non-existent keys of that type.
✗ Incorrect
SMEMBERS returns an empty list if the key does not exist or is empty.
❓ optimization
expert2:00remaining
How to efficiently retrieve all members of a very large set without blocking Redis?
You have a very large Redis set with millions of members under key
bigset. Using SMEMBERS bigset can block Redis for a long time. Which approach is best to retrieve all members without blocking?Attempts:
2 left
💡 Hint
Use a cursor-based iterator to avoid blocking.
✗ Incorrect
SSCAN allows incremental iteration over large sets without blocking Redis, unlike SMEMBERS which returns all at once.