0
0
Redisquery~20 mins

Connection configuration in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Connection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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?
Redis
SET user:1:name "Alice"
GET user:1:name
EXISTS user:1:name
DEL user:1:name
EXISTS user:1:name
A0
B1
Cnil
Derror
Attempts:
2 left
💡 Hint
EXISTS returns 1 if the key exists, 0 if it does not.
🧠 Conceptual
intermediate
1: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?
Apassword
Bretry_strategy
Ctimeout
Dmax_clients
Attempts:
2 left
💡 Hint
This option defines how the client retries connecting.
📝 Syntax
advanced
2: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?
Aconst client = redis.createClient({ password: 'mypassword', host: 'localhost', port: 6379 });
Bconst client = redis.createClient('localhost', 6379, { password: 'mypassword' });
Cconst client = redis.createClient({ host: 'localhost', port: 6379, auth_pass: 'mypassword' });
Dconst client = redis.createClient({ url: 'redis://:mypassword@localhost:6379' });
Attempts:
2 left
💡 Hint
The modern 'redis' package uses a URL string for connection including password.
optimization
advanced
2: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?
ASet max_clients to 1 to limit connections
BCreate a new Redis client for each request
CUse a single shared Redis client instance for all requests
DDisable connection pooling
Attempts:
2 left
💡 Hint
Reusing connections reduces overhead.
🔧 Debug
expert
3: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?
Redis
const client = redis.createClient({ host: 'localhost', port: 6379 });
client.auth('mypassword');
client.connect();
AThe 'auth' method is deprecated; password must be in connection options or URL
BThe port number 6379 is incorrect for password authentication
CThe 'connect' method must be called before 'auth'
DRedis does not support password authentication
Attempts:
2 left
💡 Hint
Check how the modern Redis client handles authentication.