Challenge - 5 Problems
Redis UNSUBSCRIBE Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What happens after UNSUBSCRIBE without arguments?
Consider a Redis client subscribed to channels 'news' and 'sports'. What is the output after executing
UNSUBSCRIBE with no arguments?Redis
SUBSCRIBE news sports UNSUBSCRIBE
Attempts:
2 left
💡 Hint
UNSUBSCRIBE with no arguments unsubscribes from all channels.
✗ Incorrect
When UNSUBSCRIBE is called without arguments, Redis unsubscribes the client from all channels it is currently subscribed to, sending an unsubscribe message for each channel and updating the subscription count to zero.
❓ query_result
intermediate2:00remaining
What is the output of UNSUBSCRIBE for a non-subscribed channel?
A Redis client is subscribed to channel 'chat'. What is the output after executing
UNSUBSCRIBE news where 'news' is not subscribed?Redis
SUBSCRIBE chat UNSUBSCRIBE news
Attempts:
2 left
💡 Hint
UNSUBSCRIBE sends an unsubscribe message even if the client was not subscribed to the channel.
✗ Incorrect
Redis sends an unsubscribe message for each channel requested, even if the client was not subscribed to it. The subscription count remains unchanged if the channel was not subscribed.
🧠 Conceptual
advanced2:00remaining
How does UNSUBSCRIBE affect pattern subscriptions?
If a client is subscribed to channels 'a' and 'b' and also to pattern 'p*', what happens when
UNSUBSCRIBE b is executed?Attempts:
2 left
💡 Hint
UNSUBSCRIBE affects only channel subscriptions, not pattern subscriptions.
✗ Incorrect
UNSUBSCRIBE commands affect only channel subscriptions. Pattern subscriptions remain active unless explicitly unsubscribed with PUNSUBSCRIBE.
📝 Syntax
advanced2:00remaining
What error occurs with incorrect UNSUBSCRIBE syntax?
What error does Redis return when executing
UNSUBSCRIBE 123 where 123 is a number instead of a string channel name?Attempts:
2 left
💡 Hint
Redis treats all channel names as strings internally.
✗ Incorrect
Redis accepts numeric arguments for channel names by converting them to strings internally, so no error occurs.
🔧 Debug
expert3:00remaining
Why does UNSUBSCRIBE not reduce subscription count to zero?
A client subscribed to channels 'x', 'y' and pattern 'z*' executes
UNSUBSCRIBE x y. Why does the subscription count reported remain 1 instead of 0?Attempts:
2 left
💡 Hint
Pattern subscriptions are managed separately from channel subscriptions.
✗ Incorrect
UNSUBSCRIBE only removes channel subscriptions. Pattern subscriptions remain active and count towards the subscription count, so the count stays at 1.