0
0
Redisquery~10 mins

Multi-key operations in cluster 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 get the values of multiple keys in a Redis cluster.

Redis
MGET [1]
Drag options to blanks, or click blank then click option'
Akey1,key2,key3
B[key1 key2 key3]
C"key1" "key2" "key3"
D"key1 key2 key3"
Attempts:
3 left
💡 Hint
Common Mistakes
Passing all keys as one string separated by spaces or commas.
Using brackets or commas which Redis does not accept.
2fill in blank
medium

Complete the code to set multiple keys with their values atomically using a Redis cluster.

Redis
MSET [1]
Drag options to blanks, or click blank then click option'
A"key1" "value1" "key2" "value2"
B"key1:value1 key2:value2"
Ckey1=value1 key2=value2
D[key1 value1 key2 value2]
Attempts:
3 left
💡 Hint
Common Mistakes
Combining keys and values into one string.
Using brackets or commas which Redis does not accept.
3fill in blank
hard

Fix the error in the command to delete multiple keys in a Redis cluster.

Redis
DEL [1]
Drag options to blanks, or click blank then click option'
A"key1" "key2" "key3"
B"key1 key2 key3"
Ckey1,key2,key3
D[key1 key2 key3]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing all keys as one string.
Using commas or brackets which Redis does not accept.
4fill in blank
hard

Fill both blanks to correctly perform a multi-key atomic increment operation in Redis cluster using Lua script.

Redis
EVAL "return redis.call('INCRBY', [1], [2])" 0
Drag options to blanks, or click blank then click option'
A'key1'
B'key2'
C5
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong key names or missing quotes.
Passing increment as a string instead of number or vice versa.
5fill in blank
hard

Fill all three blanks to create a Redis Lua script that atomically sets a key only if it does not exist and returns the new value.

Redis
EVAL "if redis.call('SETNX', [1], [2]) == 1 then return redis.call('GET', [3]) else return nil end" 0
Drag options to blanks, or click blank then click option'
A'mykey'
B'100'
D'otherkey'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different keys in SETNX and GET calls.
Passing values without quotes.