Challenge - 5 Problems
Redis CLI Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediateWhat is the output of this Redis CLI command?
Assume the Redis database is empty. You run the following commands in redis-cli:
SET user:1 "Alice"
GET user:1
What will be the output of the GET command?
SET user:1 "Alice"
GET user:1
What will be the output of the GET command?
Redis
SET user:1 "Alice" GET user:1
Attempts:
2 left
💡 Hint
GET returns the value stored at the key if it exists.
✗ Incorrect
The SET command stores the string "Alice" at key user:1. The GET command retrieves that value, so it returns "Alice".
📝 Syntax
intermediateWhich Redis CLI command syntax is correct to add a member to a set?
You want to add the member "blue" to the set stored at key "colors". Which command is correct?
Attempts:
2 left
💡 Hint
The command to add members to a set starts with SADD.
✗ Incorrect
SADD is the Redis command to add one or more members to a set. ADD, SET, and PUSH are either invalid or used for other data types.
❓ query_result
advancedWhat is the output of this Redis CLI command sequence?
Assuming the database is empty, you run:
LPUSH fruits apple banana cherry
LRANGE fruits 0 1
What is the output of the LRANGE command?
LPUSH fruits apple banana cherry
LRANGE fruits 0 1
What is the output of the LRANGE command?
Redis
LPUSH fruits apple banana cherry LRANGE fruits 0 1
Attempts:
2 left
💡 Hint
LPUSH adds elements to the head of the list in the order given.
✗ Incorrect
LPUSH adds elements from left to right to the head, so the list becomes [cherry, banana, apple]. LRANGE 0 1 returns the first two elements: cherry and banana.
🔧 Debug
advancedWhy does this Redis CLI command return an error?
You run the command:
INCR mykey
But Redis returns an error: "ERR value is not an integer or out of range". What is the most likely cause?
INCR mykey
But Redis returns an error: "ERR value is not an integer or out of range". What is the most likely cause?
Redis
INCR mykey
Attempts:
2 left
💡 Hint
INCR only works on keys holding integer values or keys that do not exist.
✗ Incorrect
If 'mykey' exists but holds a non-integer string, INCR returns an error. If the key does not exist, INCR creates it with value 1.
🧠 Conceptual
expertWhich Redis CLI command sequence correctly sets a key with expiration and verifies it?
You want to set key "session" to "active" with a 10-second expiration, then check the remaining time to live. Which sequence is correct?
Attempts:
2 left
💡 Hint
SETEX sets a key with expiration in seconds in one command.
✗ Incorrect
SETEX key seconds value sets the key with expiration in seconds. TTL returns the remaining time to live in seconds. Option D uses SET with EX correctly.
