Challenge - 5 Problems
Redis SET and GET 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 Redis command sequence?
Consider the following Redis commands executed in order:
What will the GET command return?
SET user:1 "Alice"GET user:1What will the GET command return?
Redis
SET user:1 "Alice" GET user:1
Attempts:
2 left
💡 Hint
The SET command stores a value for a key. GET retrieves that value.
✗ Incorrect
The SET command stores the string "Alice" under the key "user:1". The GET command then returns the stored value, which is "Alice".
❓ query_result
intermediate1:00remaining
What happens when you GET a non-existing key?
If you run the command
GET missing_key on Redis where no such key exists, what is the output?Redis
GET missing_key
Attempts:
2 left
💡 Hint
Redis returns a special value when keys are missing.
✗ Incorrect
When a key does not exist, Redis returns nil to indicate no value is stored.
📝 Syntax
advanced1:30remaining
Which command syntax correctly sets a key with expiration of 10 seconds?
You want to set key "session" with value "xyz" that expires after 10 seconds. Which command is correct?
Attempts:
2 left
💡 Hint
EX sets expiration in seconds, PX in milliseconds.
✗ Incorrect
The correct syntax to set expiration in seconds is using EX option with SET command.
❓ query_result
advanced1:30remaining
What is the output after overwriting a key?
Given these commands:
What does the GET command return?
SET color "red"SET color "blue"GET colorWhat does the GET command return?
Redis
SET color "red" SET color "blue" GET color
Attempts:
2 left
💡 Hint
SET overwrites existing keys with new values.
✗ Incorrect
The second SET command overwrites the value of "color" to "blue". GET returns the latest value.
🧠 Conceptual
expert2:00remaining
Why does GET return nil after key expiration?
You set a key with expiration using
SET key value EX 5. After 6 seconds, you run GET key. Why does it return nil?Attempts:
2 left
💡 Hint
Expiration removes the key from the database.
✗ Incorrect
When a key expires, Redis deletes it automatically. GET then returns nil because the key no longer exists.