Challenge - 5 Problems
SUNIONSTORE Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
What is the result of SUNIONSTORE command?
Given two Redis sets:
SET1 contains {"apple", "banana"}
SET2 contains {"banana", "cherry"}
What will be the number of elements in the destination set after running:
SET1 contains {"apple", "banana"}
SET2 contains {"banana", "cherry"}
What will be the number of elements in the destination set after running:
SUNIONSTORE dest SET1 SET2?Redis
SUNIONSTORE dest SET1 SET2
Attempts:
2 left
💡 Hint
SUNIONSTORE stores the union of all members from the given sets into the destination key.
✗ Incorrect
The union of {"apple", "banana"} and {"banana", "cherry"} is {"apple", "banana", "cherry"}, which has 3 elements.
🧠 Conceptual
intermediate1:00remaining
What does SUNIONSTORE do in Redis?
Choose the correct description of the Redis command SUNIONSTORE.
Attempts:
2 left
💡 Hint
SUNIONSTORE combines sets and saves the result.
✗ Incorrect
SUNIONSTORE computes the union of given sets and stores the result in a destination key.
📝 Syntax
advanced1:30remaining
Which SUNIONSTORE command syntax is correct?
Identify the correct Redis SUNIONSTORE command syntax to store the union of sets 'setA' and 'setB' into 'resultSet'.
Attempts:
2 left
💡 Hint
The first argument after SUNIONSTORE is the destination key.
✗ Incorrect
The syntax is SUNIONSTORE destination_key key1 [key2 ...]. Option A follows this order correctly.
❓ optimization
advanced2:00remaining
How to optimize multiple SUNIONSTORE operations?
You need to store the union of three sets: set1, set2, and set3 into 'finalSet'. Which approach is more efficient?
Attempts:
2 left
💡 Hint
SUNIONSTORE accepts multiple sets at once.
✗ Incorrect
SUNIONSTORE can take multiple keys to union in one command, which is more efficient than chaining commands.
🔧 Debug
expert2:00remaining
Why does this SUNIONSTORE command fail?
Given the command:
Assuming set1 and set2 are valid sets, why does this command fail?
SUNIONSTORE resultSet set1 set2 123Assuming set1 and set2 are valid sets, why does this command fail?
Redis
SUNIONSTORE resultSet set1 set2 123Attempts:
2 left
💡 Hint
Redis keys can be strings, but numeric strings are allowed if used consistently.
✗ Incorrect
Redis keys can be any string, including numeric strings, so '123' is valid as a key name. The command does not fail for that reason. However, if '123' does not exist as a set, it is treated as an empty set, so no error occurs. The actual failure is if the key is not a set type. But since the question states failure, the only plausible reason is that '123' is not a set type key, causing a type error.