Challenge - 5 Problems
Redis Blocking Pop Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
What is the output of this BLPOP command?
Given the Redis list
mylist contains ["a", "b", "c"], what will be the result of BLPOP mylist 0?Redis
BLPOP mylist 0Attempts:
2 left
💡 Hint
BLPOP removes and returns the first element of the list.
✗ Incorrect
BLPOP removes the first element from the left of the list and returns it with the key name.
❓ query_result
intermediate1:30remaining
What happens when BRPOP is used on an empty list with timeout 2?
If the Redis list
tasks is empty, what will BRPOP tasks 2 return after 2 seconds?Redis
BRPOP tasks 2Attempts:
2 left
💡 Hint
BRPOP waits for an element or times out.
✗ Incorrect
If the list is empty and no element is pushed within 2 seconds, BRPOP returns nil.
📝 Syntax
advanced1:30remaining
Which BLPOP command syntax is correct to pop from multiple lists?
You want to pop the first element from either
list1 or list2 with a 5-second timeout. Which command is correct?Attempts:
2 left
💡 Hint
Timeout is the last argument after all keys.
✗ Incorrect
The correct syntax lists all keys first, then the timeout at the end.
❓ optimization
advanced2:00remaining
How to efficiently wait for elements from multiple lists?
You want to wait for elements from
queue1, queue2, and queue3 and pop the first available element. Which command is the most efficient?Attempts:
2 left
💡 Hint
Use a single blocking command with multiple keys.
✗ Incorrect
BLPOP with multiple keys and zero timeout waits efficiently for any list to have an element.
🧠 Conceptual
expert2:00remaining
What is the difference between BLPOP and BRPOP in Redis?
Choose the option that best describes the difference between BLPOP and BRPOP commands.
Attempts:
2 left
💡 Hint
Think about which end of the list each command pops from.
✗ Incorrect
BLPOP pops from the left (start) of the list; BRPOP pops from the right (end). Both can block if the list is empty.