Challenge - 5 Problems
Redis Connection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this Redis command sequence?
Consider the following Redis commands executed in order:
1. SET user:1:name "Alice"
2. GET user:1:name
3. EXISTS user:1:name
4. DEL user:1:name
5. EXISTS user:1:name
What is the output of the last EXISTS command?
1. SET user:1:name "Alice"
2. GET user:1:name
3. EXISTS user:1:name
4. DEL user:1:name
5. EXISTS user:1:name
What is the output of the last EXISTS command?
Redis
SET user:1:name "Alice" GET user:1:name EXISTS user:1:name DEL user:1:name EXISTS user:1:name
Attempts:
2 left
💡 Hint
EXISTS returns 1 if the key exists, 0 if it does not.
✗ Incorrect
After deleting the key 'user:1:name', the EXISTS command returns 0 because the key no longer exists.
🧠 Conceptual
intermediate1:30remaining
Which Redis connection option ensures automatic reconnection on connection loss?
You want your Redis client to automatically reconnect if the connection drops. Which connection configuration option should you use?
Attempts:
2 left
💡 Hint
This option defines how the client retries connecting.
✗ Incorrect
The 'retry_strategy' option configures automatic reconnection attempts when the connection is lost.
📝 Syntax
advanced2:30remaining
Which Redis client connection code snippet is syntactically correct for connecting with a password?
Given these four code snippets for connecting to Redis with a password, which one is syntactically correct in Node.js using the 'redis' package?
Attempts:
2 left
💡 Hint
The modern 'redis' package uses a URL string for connection including password.
✗ Incorrect
Option D uses the correct URL format with password embedded. Other options use deprecated or incorrect syntax.
❓ optimization
advanced2:00remaining
How to optimize Redis connection for high throughput in a Node.js app?
You have a Node.js app that makes many Redis requests. Which connection configuration improves throughput best?
Attempts:
2 left
💡 Hint
Reusing connections reduces overhead.
✗ Incorrect
Using a single shared client avoids overhead of reconnecting and improves throughput.
🔧 Debug
expert3:00remaining
Why does this Redis connection code fail to authenticate?
You run this Node.js code to connect to Redis with a password but get an authentication error:
const client = redis.createClient({ host: 'localhost', port: 6379 });
client.auth('mypassword');
client.connect();
What is the reason for the failure?
const client = redis.createClient({ host: 'localhost', port: 6379 });
client.auth('mypassword');
client.connect();
What is the reason for the failure?
Redis
const client = redis.createClient({ host: 'localhost', port: 6379 });
client.auth('mypassword');
client.connect();Attempts:
2 left
💡 Hint
Check how the modern Redis client handles authentication.
✗ Incorrect
Modern Redis clients require password in connection options or URL; calling 'auth' separately is deprecated and causes failure.