0
0
Redisquery~10 mins

Client-side cluster support in Redis - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to connect to a Redis cluster using the client.

Redis
const cluster = new Redis.Cluster([1]);
Drag options to blanks, or click blank then click option'
A[{ host: '127.0.0.1', port: 7000 }]
B'127.0.0.1:7000'
C{ host: '127.0.0.1', port: 7000 }
D7000
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single string instead of an array.
Passing a single object instead of an array.
Passing only the port number.
2fill in blank
medium

Complete the code to execute a command on the Redis cluster client.

Redis
cluster.[1]('set', 'key', 'value');
Drag options to blanks, or click blank then click option'
Aexecute
Bcall
CsendCommand
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using execute or call which are not valid methods.
Using run which does not exist.
3fill in blank
hard

Fix the error in the code to properly handle cluster node errors.

Redis
cluster.on('error', [1] => { console.error('Cluster error:', err); });
Drag options to blanks, or click blank then click option'
Aerror
Berr
Ce
Dexception
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different parameter name than the one used inside the function.
Not matching the parameter name with the error object.
4fill in blank
hard

Fill both blanks to create a command that gets the value of a key from the cluster.

Redis
const value = await cluster.[1]('get', [2]);
Drag options to blanks, or click blank then click option'
AsendCommand
B'mykey'
C'key1'
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using execute instead of sendCommand.
Passing the wrong key string.
5fill in blank
hard

Fill all three blanks to create a cluster client, set a key, and get its value.

Redis
const cluster = new Redis.Cluster([1]);
await cluster.[2]('set', 'name', 'Alice');
const name = await cluster.[3]('get', 'name');
Drag options to blanks, or click blank then click option'
A[{ host: 'localhost', port: 7001 }]
BsendCommand
D[{ host: '127.0.0.1', port: 6379 }]
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong node addresses.
Using different methods instead of sendCommand.